Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

   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
.\" Copyright (C) Caldera International Inc. 2001-2002.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are
.\" met:
.\"
.\" Redistributions of source code and documentation must retain the above
.\" copyright notice, this list of conditions and the following
.\" disclaimer.
.\"
.\" Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\"
.\" This product includes software developed or owned by Caldera
.\" International, Inc.  Neither the name of Caldera International, Inc.
.\" nor the names of other contributors may be used to endorse or promote
.\" products derived from this software without specific prior written
.\" permission.
.\"
.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
.\" INTERNATIONAL, INC.  AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
.\" DISCLAIMED.  IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
.\" FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\"	@(#)Clang.ms	8.1 (Berkeley) 6/8/93
.\"
.\" $FreeBSD$
.nr Cl 2
.TL
The C Programming Language - Reference Manual
.AU
Dennis M. Ritchie
.AI
AT&T Bell Laboratories
Murray Hill, NJ 07974
.PP
This manual is a reprint, with updates to the current C standard, from
\fIThe C Programming Language\fR,
by Brian W. Kernighan and Dennis M. Ritchie, Prentice-Hall, Inc., 1978.
.PP
\fBThis document is of historical interest only.  Do not use it as a reference
for modern implementations of C.\fP
.EH 'PSD:6-%''The C Programming Language - Reference Manual'
.OH 'The C Programming Language - Reference Manual''PSD:6-%'
.NH 1
Introduction
.PP
This manual describes the C language on the DEC PDP-11\(dg, the DEC VAX-11,
.FS
.LP
\(dg DEC PDP-11, and DEC VAX-11 are trademarks of Digital Equipment Corporation.
.LP
\(dd 3B 20 is a trademark of AT&T.
.FE
and the AT&T 3B 20\(dd.
Where differences exist, it concentrates on the VAX, but tries to point
out implementation-dependent details.  With few exceptions, these dependencies
follow directly from the underlying properties of the hardware; the various
compilers are generally quite compatible.
.NH 1
Lexical Conventions
.PP
There are six classes of tokens\ -\
identifiers, keywords, constants, strings, operators, and other separators.
Blanks, tabs, new\(hylines,
and comments (collectively, ``white space'') as described below
are ignored except as they serve to separate
tokens.
Some white space is required to separate
otherwise adjacent identifiers,
keywords, and constants.
.PP
If the input stream has been parsed into tokens
up to a given character, the next token is taken
to include the longest string of characters
which could possibly constitute a token.
.NH 2
Comments
.PP
The characters
.B
/*
.R
introduce a comment which terminates
with the characters
\fB\(**/\fR.
Comments do not nest.
.NH 2
Identifiers (Names)
.PP
An identifier is a sequence of letters and digits.
The first character must be a letter.
The underscore
(\fB_\fR)
counts as a letter.
Uppercase and lowercase letters
are different.
Although there is no limit on the length of a name,
only initial characters are significant: at least
eight characters of a non-external name, and perhaps
fewer for external names.
Moreover, some implementations may collapse case
distinctions for external names.
The external name sizes include:
.DS
.TS
l l.
PDP-11	7 characters, 2 cases
VAX-11	>100 characters, 2 cases
AT&T 3B 20	>100 characters, 2 cases
.TE
.fi
.DE
.NH 2
Keywords
.PP
The following identifiers are reserved for use
as keywords and may not be used otherwise:
.DS
.ta 0.8i 1.6i 2.4i 3.2i 4.0i
\fBauto	do	for	return	typedef
break	double	goto	short	union
case	else	if	sizeof	unsigned
char	enum	int	static	void
continue	external	long	struct	while
default	float	register	switch\fR
.ta 0.5i
.DE
.PP
Some implementations also reserve the words
.B
fortran, asm, gfloat, hfloat
.R
and
.B quad
.R
.NH 2
Constants
.PP
There are several kinds
of constants.
Each has a type; an introduction to types is given in ``NAMES.''
Hardware characteristics that affect sizes are summarized in
``Hardware Characteristics'' under ``LEXICAL CONVENTIONS.''
.NH 3
Integer Constants
.br
.PP
An integer constant consisting of a sequence of digits
is taken
to be octal if it begins with
.B
0
.R
(digit zero).
An octal constant consists of the digits \fB0\fR through \fB7\fR only.
A sequence of digits preceded by
.B
0x
.R
or
.B
0X
.R
(digit zero) is taken to be a hexadecimal integer.
The hexadecimal digits include
.B
a
.R
or
.B
A
.R
through
.B
f
.R
or
.B
F
.R
with values 10 through 15.
Otherwise, the integer constant is taken to be decimal.
A decimal constant whose value exceeds the largest
signed machine integer is taken to be
\fBlong\fR;
an octal or hex constant which exceeds the largest unsigned machine integer
is likewise taken to be
.B
long\fR.
.R
Otherwise, integer constants are \fBint\fR.
.NH 3
Explicit Long Constants
.br
.PP
A decimal, octal, or hexadecimal integer constant immediately followed
by
.B
l
.R
(letter ell)
or
.B
L
.R
is a long constant.
As discussed below,
on some machines
integer and long values may be considered identical.
.NH 3
Character Constants
.br
.PP
A character constant is a character enclosed in single quotes,
as in '\fBx\fR'.
The value of a character constant is the numerical value of the
character in the machine's character set.
.PP
Certain nongraphic characters,
the single quote
(\fB'\fR)
and the backslash
(\fB\e\fR),
may be represented according to the following table
of escape sequences:
.DS
.TS
l l l.
new\(hyline	NL (LF)	\en
horizontal tab	HT	\et
vertical tab	VT	\ev
backspace	BS	\eb
carriage return	CR	\er
form feed	FF	\ef
backslash	\e	\e\e
single quote	'	\e'
bit pattern	\fIddd\fR\^	\e\fIddd\fR\^
.TE
.DE
.PP
The escape
\e\fIddd\fR
consists of the backslash followed by 1, 2, or 3 octal digits
which are taken to specify the value of the
desired character.
A special case of this construction is
.B
\e0
.R
(not followed
by a digit), which indicates the character
.B
NUL\fR.
.R
If the character following a backslash is not one
of those specified, the
behavior is undefined.
A new-line character is illegal in a character constant.
The type of a character constant is \fBint\fR.
.NH 3
Floating Constants
.br
.PP
A floating constant consists of
an integer part, a decimal point, a fraction part,
an
.B
e
.R
or
\fBE\fR,
and an optionally signed integer exponent.
The integer and fraction parts both consist of a sequence
of digits.
Either the integer part or the fraction
part (not both) may be missing.
Either the decimal point or
the
.B
e
.R
and the exponent (not both) may be missing.
Every floating constant has type \fBdouble\fR.
.NH 3
Enumeration Constants
.br
.PP
Names declared as enumerators
(see ``Structure, Union, and Enumeration Declarations'' under
``DECLARATIONS'')
have type \fBint\fR.
.NH 2
Strings
.PP
A string is a sequence of characters surrounded by
double quotes,
as in
\fB"..."\fR.
A string has type
``array of \fBchar\fR'' and storage class
\fBstatic\fR
(see ``NAMES'')
and is initialized with
the given characters.
The compiler places
a null byte
(\fB\e0\fR)
at the end of each string so that programs
which scan the string can
find its end.
In a string, the double quote character
(\fB"\fR)
must be preceded by
a
\fB\e\fR;
in addition, the same escapes as described for character
constants may be used.
.PP
A
.B
\e
.R
and
the immediately following new\(hyline are ignored.
All strings, even when written identically, are distinct.
.NH 2
Hardware Characteristics
.PP
The following figure summarize
certain hardware properties that vary from machine to machine.
.DS
.TS
center box;
c cfB s cfB s cfB s
c c s c s c s
l | l1 lp8 | l1 lp8 | l1 lp8.
	DEC PDP\-11	DEC VAX-11	AT&T 3B
	(ASCII)	(ASCII)	(ASCII)
.sp
_
char	8 bits		8 bits		8bits
int	16		32		32
short	16		16		16
long	32		32		32
float	32		32		32
double	64		64		64
float range	   \(+-10	\(+-38	   \(+-10	\(+-38	    \(+-10	\(+-38
\^	\^		\^		\^
double range	   \(+-10	\(+-38	   \(+-10	\(+-38	    \(+-10	\(+-308
\^	\^		\^		\^
.TE
.\" .FG 4 4 1 "DEC PDP-11 HARDWARE CHARACTERISTICS"
.DE
.PP
.NH 1
Syntax Notation
.PP
Syntactic categories are indicated by
.I
italic
.R
type
and literal words and characters
in
\fBbold\fR
type.
Alternative categories are listed on separate lines.
An optional terminal or nonterminal symbol is
indicated by the subscript ``opt,'' so that
.DS
{ \fIexpression\v'0.5'\s-2opt\s0\v'-0.5'\fR }
.DE
.LP
indicates an optional expression enclosed in braces.
The syntax is summarized in ``SYNTAX SUMMARY''.
.NH 1
Names
.PP
The C language bases the interpretation of an
identifier upon two attributes of the identifier \(mi its
.I
storage class
.R
and its
.I
type\fR.
The storage class determines the location and lifetime
of the storage associated with an identifier;
the type determines
the meaning of the values
found in the identifier's storage.
.NH 2
Storage Class
.PP
.\" The original text had borrowed BL, LI and LE from the mm macros.
.\" That way madness lies.
There are four declarable storage classes:
.RS
.br
\(bu Automatic
.br
\(bu Static
.br
\(bu External
.br
\(bu Register.
.RE
.PP
Automatic variables are local to each invocation of
a block (see ``Compound Statement or Block'' in
``STATEMENTS'') and are discarded upon exit from the block.
Static variables are local to a block but retain
their values upon reentry to a block even after control
has left the block.
External variables exist and retain their values throughout
the execution of the entire program and
may be used for communication between
functions, even separately compiled functions.
Register variables are (if possible) stored in the fast registers
of the machine; like automatic
variables, they are local to each block and disappear on exit from the block.
.NH 2
Type
.PP
The C language supports several
fundamental
types of objects.
Objects declared as characters
(\fBchar\fR)
are large enough to store any member of the implementation's
character set.
If a genuine character from that character set is
stored in a \fBchar\fR variable,
its value is equivalent to the integer code for that character.
Other quantities may be stored into character variables, but
the implementation is machine dependent.
In particular, \fBchar\fR may be signed or unsigned by default.
.PP
Up to three sizes of integer, declared
.B
short
.R
\fBint\fR,
\fBint\fR,
and
.B
long
.R
\fBint\fR,
are available.
Longer integers provide no less storage than shorter ones,
but the implementation may make either short integers or long integers,
or both, equivalent to plain integers.
``Plain'' integers have the natural size suggested
by the host machine architecture.
The other sizes are provided to meet special needs.
.PP
The properties of \fBenum\fR types (see ``Structure, Union, and Enumeration Declarations''
under ``DECLARATIONS'')
are identical to those of
some integer types.
The implementation may use the range of values to
determine how to allocate storage.
.PP
Unsigned
integers, declared
.B
unsigned,
.R
obey the laws of arithmetic modulo
2\v'-0.5'\fIn\fR\v'0.5'
where \fIn\fR is the number of bits in the representation.
(On the
PDP-11,
unsigned long quantities are not supported.)
.PP
Single-precision floating point
(\fBfloat\fR)
and double precision floating point
(\fBdouble\fR)
may be synonymous in some implementations.
.PP
Because objects of the foregoing types can usefully be interpreted
as numbers, they will be referred to as
.I
arithmetic
.R
types.
\fBChar\fR,
.B
int
.R
of all sizes whether \fBunsigned\fR or not, and
.B
enum
.R
will collectively be called
.I
integral
.R
types.
The
.B
float
.R
and
.B
double
.R
types will collectively be called
.I
floating
.R
types.
.PP
The
.B
void
.R
type
specifies an empty set of values.
It is used as the type returned by functions that
generate no value.
.PP
Besides the fundamental arithmetic types, there is a
conceptually infinite class of derived types constructed
from the fundamental types in the following ways:
.IP \fIArrays\fR
of objects of most types
.IP \fIFunctions\fR
which return objects of a given type
.IP \fIPointers\fR
to objects of a given type
.IP \fIStructures\fR
containing a sequence of objects of various types
.IP \fIUnions\fR
capable of containing any one of several objects of various types.
.LP
In general these methods
of constructing objects can
be applied recursively.
.NH 1
Objects and Lvalues
.PP
An
.I
object
.R
is a manipulatable region of storage.
An
.I
lvalue
.R
is an expression referring to an object.
An obvious example of an lvalue
expression is an identifier.
There are operators which yield lvalues:
for example,
if
.B
E
.R
is an expression of pointer type, then
.B
\(**E
.R
is an lvalue
expression referring to the object to which
.B
E
.R
points.
The name ``lvalue'' comes from the assignment expression
.B
E1\ =\ E2
.R
in which the left operand
.B
E1
.R
must be
an lvalue expression.
The discussion of each operator
below indicates whether it expects lvalue operands and whether it
yields an lvalue.
.NH 1
Conversions
.PP
A number of operators may, depending on their operands,
cause conversion of the value of an operand from one type to another.
This part explains the result to be expected from such
conversions.
The conversions demanded by most ordinary operators are summarized under
``Arithmetic Conversions.''
The summary will be supplemented
as required by the discussion
of each operator.
.NH 2
Characters and Integers
.PP
A character or a short integer may be used wherever an
integer may be used.
In all cases
the value is converted to an integer.
Conversion of a shorter integer
to a longer preserves sign.
Whether or not sign-extension occurs for characters is machine
dependent, but it is guaranteed that a member of the
standard character set is non-negative.
Of the machines treated here,
only the
PDP-11
and
VAX-11
sign-extend.
On these machines,
.B
char
.R
variables range in value from
\(mi128 to 127.
The more explicit type
.B
unsigned
.R
.B
char
.R
forces the values to range from 0 to 255.
.PP
On machines that treat characters as signed,
the characters of the
ASCII
set are all non-negative.
However, a character constant specified
with an octal escape suffers sign extension
and may appear negative;
for example,
\fB\'\e377\'\fR
\fRhas the value
.B
\(mi1\fR.
.PP
When a longer integer is converted to a shorter
integer
or to a
.B
char,
.R
it is truncated on the left.
Excess bits are simply discarded.
.NH 2
Float and Double
.PP
All floating arithmetic in C is carried out in double precision.
Whenever a
.B
float
.R
appears in an expression it is lengthened to
.B
double
.R
by zero padding its fraction.
When a
.B
double
.R
must be
converted to
\fBfloat\fR,
for example by an assignment,
the
.B
double
.R
is rounded before
truncation to
.B
float
.R
length.
This result is undefined if it cannot be represented as a float.
On the VAX, the compiler can be directed to use single precision for expressions
containing only float and integer operands.
.NH 2
Floating and Integral
.PP
Conversions of floating values to integral type
are rather machine dependent.
In particular, the direction of truncation of negative numbers
varies.
The result is undefined if
it will not fit in the space provided.
.PP
Conversions of integral values to floating type
are well behaved.
Some loss of accuracy occurs
if the destination lacks sufficient bits.
.NH 2
Pointers and Integers
.PP
An expression of integral type may be added to or subtracted from
a pointer; in such a case,
the first is converted as
specified in the discussion of the addition operator.
Two pointers to objects of the same type may be subtracted;
in this case, the result is converted to an integer
as specified in the discussion of the subtraction
operator.
.NH 2
Unsigned
.PP
Whenever an unsigned integer and a plain integer
are combined, the plain integer is converted to unsigned
and the result is unsigned.
The value
is the least unsigned integer congruent to the signed
integer (modulo 2\v'-0.3'\s-2wordsize\s+2\v'0.3').
In a 2's complement representation,
this conversion is conceptual; and there is no actual change in the
bit pattern.
.PP
When an unsigned \fBshort\fR integer is converted to
\fBlong\fR,
the value of the result is the same numerically as that of the
unsigned integer.
Thus the conversion amounts to padding with zeros on the left.
.NH 2
Arithmetic Conversions
.PP
A great many operators cause conversions
and yield result types in a similar way.
This pattern will be called the ``usual arithmetic conversions.''
.IP 1.
First, any operands of type
.B
char
.R
or
.B
short
.R
are converted to
\fBint\fR,
and any operands of type \fBunsigned char\fR
or \fBunsigned short\fR are converted
to \fBunsigned int\fR.
.IP 2.
Then, if either operand is
.B
double,
.R
the other is converted to
.B
double
.R
and that is the type of the result.
.IP 3.
Otherwise, if either operand is \fBunsigned long\fR,
the other is converted to \fBunsigned long\fR and that
is the type of the result.
.IP 4.
Otherwise, if either operand is
\fBlong\fR,
the other is converted to
.B
long
.R
and that is the type of the result.
.IP 5.
Otherwise, if one operand is \fBlong\fR, and
the other is \fBunsigned int\fR, they are both
converted to \fBunsigned long\fR and that is
the type of the result.
.IP 6.
Otherwise, if either operand is
.B
unsigned,
.R
the other is converted to
.B
unsigned
.R
and that is the type of the result.
.IP 7.
Otherwise, both operands must be
\fBint\fR,
and that is the type of the result.
.LP
.NH 2
Void
.PP
The (nonexistent) value of a
.B
void
.R
object may not be used in any way,
and neither explicit nor implicit conversion may be applied.
Because a void expression denotes a nonexistent value,
such an expression may be used only
as an expression statement
(see ``Expression Statement'' under ``STATEMENTS'')
or as the left operand
of a comma expression (see ``Comma Operator'' under ``EXPRESSIONS'').
.PP
An expression may be converted to
type
.B
void
.R
by use of a cast.
For example, this makes explicit the discarding of the value
of a function call used as an expression statement.
.NH 1
Expressions
.PP
The precedence of expression operators is the same
as the order of the major
subsections of this section, highest precedence first.
Thus, for example, the expressions referred to as the operands of
.B
\(pl
.R
(see ``Additive Operators'')
are those expressions defined under ``Primary Expressions'',
``Unary Operators'', and ``Multiplicative Operators''.
Within each subpart, the operators have the same
precedence.
Left- or right-associativity is specified
in each subsection for the operators
discussed therein.
The precedence and associativity of all the expression
operators are summarized in the
grammar of ``SYNTAX SUMMARY''.
.PP
Otherwise, the order of evaluation of expressions
is undefined.  In particular, the compiler
considers itself free to
compute subexpressions in the order it believes
most efficient
even if the subexpressions
involve side effects.
The order in which subexpression evaluation takes place is unspecified.
Expressions involving a commutative and associative
operator
(\fB\(**,\fR
\fB\(pl\fR,
\fB&\fR,
\fB|\fR,
\fB^\fR)
may be rearranged arbitrarily even in the presence
of parentheses;
to force a particular order of evaluation,
an explicit temporary must be used.
.PP
The handling of overflow and divide check
in expression evaluation
is undefined.
Most existing implementations of C ignore integer overflows;
treatment of
division by 0 and all floating-point exceptions
varies between machines and is usually
adjustable by a library function.
.NH 2
Primary Expressions
.PP
Primary expressions
involving \fB\.\fR,
\fB\(mi>\fR,
subscripting, and function calls
group left to right.
.DS
\fIprimary-expression:
        identifier
        constant
        string
        ( expression )
        primary-expression [ expression ]
        primary-expression ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
        primary-expression . identifier
        primary-expression \(mi> identifier\fR
.DE
.DS
\fIexpression-list:
        expression
        expression-list , expression\fR
.DE
.PP
An identifier is a primary expression provided it has been
suitably declared as discussed below.
Its type is specified by its declaration.
If the type of the identifier is ``array of .\|.\|.'',
then the value of the identifier expression
is a pointer
to the first object in the array; and the
type of the expression is
``pointer to .\|.\|.''.
Moreover, an array identifier is not an lvalue
expression.
Likewise, an identifier which is declared
``function returning .\|.\|.'',
when used except in the function-name position
of a call, is converted to ``pointer to function returning .\|.\|.''.
.PP
A
constant is a primary expression.
Its type may be
\fBint\fR,
\fBlong\fR,
or
.B
double
.R
depending on its form.
Character constants have type
.B
int
.R
and floating constants have type
.B
double\fR.
.R
.PP
A string is a primary expression.
Its type is originally ``array of
\fBchar\fR'',
but following
the same rule given above for identifiers,
this is modified to ``pointer to
\fBchar\fR'' and
the
result is a pointer to the first character
in the string.
(There is an exception in certain initializers;
see ``Initialization'' under ``DECLARATIONS.'')
.PP
A parenthesized expression is a primary expression
whose type and value are identical
to those of the unadorned expression.
The presence of parentheses does
not affect whether the expression is an
lvalue.
.PP
A primary expression followed by an expression in square
brackets is a primary expression.
The intuitive meaning is that of a subscript.
Usually, the primary expression has type ``pointer to .\|.\|.'',
the subscript expression is
\fBint\fR,
and the type of the result is ``\|.\|.\|.\|''.
The expression
.B
E1[E2]
.R
is
identical (by definition) to
.B
\(**((E1)\(plE2))\fR.
All the clues
needed to understand
this notation are contained in this subpart together
with the discussions
in ``Unary Operators'' and ``Additive Operators'' on identifiers,
.B
\(**
.R
and
.B
\(pl
.R
respectively.
The implications are summarized under ``Arrays, Pointers, and Subscripting''
under ``TYPES REVISITED.''
.PP
A function call is a primary expression followed by parentheses
containing a possibly
empty, comma-separated list of expressions
which constitute the actual arguments to the
function.
The primary expression must be of type ``function returning .\|.\|.,''
and the result of the function call is of type ``\|.\|.\|.\|''.
As indicated
below, a hitherto unseen identifier followed
immediately by a left parenthesis
is contextually declared
to represent a function returning
an integer;
thus in the most common case, integer-valued functions
need not be declared.
.PP
Any actual arguments of type
.B
float
.R
are
converted to
.B
double
.R
before the call.
Any of type
.B
char
.R
or
.B
short
.R
are converted to
.B
int\fR.
.R
Array names are converted to pointers.
No other conversions are performed automatically;
in particular, the compiler does not compare
the types of actual arguments with those of formal
arguments.
If conversion is needed, use a cast;
see ``Unary Operators'' and ``Type Names'' under
``DECLARATIONS.''
.PP
In preparing for the call to a function,
a copy is made of each actual parameter.
Thus, all argument passing in C is strictly by value.
A function may
change the values of its formal parameters, but
these changes cannot affect the values
of the actual parameters.
It is possible
to pass a pointer on the understanding
that the function may change the value
of the object to which the pointer points.
An array name is a pointer expression.
The order of evaluation of arguments is undefined by the language;
take note that the various compilers differ.
Recursive calls to any
function are permitted.
.PP
A primary expression followed by a dot followed by an identifier
is an expression.
The first expression must be a structure or a union, and the identifier
must name a member of the structure or union.
The value is the named member of the structure or union, and it is
an lvalue if the first expression is an lvalue.
.PP
A primary expression followed by an arrow (built from
.B
\(mi
.R
and
.B
>
.R
)
followed by an identifier
is an expression.
The first expression must be a pointer to a structure or a union
and the identifier must name a member of that structure or union.
The result is an lvalue referring to the named member
of the structure or union
to which the pointer expression points.
Thus the expression
.B
E1\(mi>MOS
.R
is the same as
.B
(\(**E1).MOS\fR.
.R
Structures and unions are discussed in
``Structure, Union, and Enumeration Declarations'' under
``DECLARATIONS.''
.NH 2
Unary Operators
.PP
Expressions with unary operators
group right to left.
.tr ~~
.DS
\fIunary-expression:
        \(** expression
        & lvalue
        \(mi expression
        ! expression
        \s+2~\s0 expression
        \(pl\(pl lvalue
        \(mi\(milvalue
        lvalue \(pl\(pl
        lvalue \(mi\(mi
        ( type-name ) expression\fR
        sizeof\fI expression\fR
        sizeof\fI ( type-name )\fR
.DE
.PP
The unary
.B
\(**
.R
operator
means
.I
indirection
.R
;
the expression must be a pointer, and the result
is an lvalue referring to the object to
which the expression points.
If the type of the expression is ``pointer to .\|.\|.,''
the type of the result is ``\|.\|.\|.\|''.
.PP
The result of the unary
.B
&
.R
operator is a pointer
to the object referred to by the
lvalue.
If the type of the lvalue is ``\|.\|.\|.\|'',
the type of the result is ``pointer to .\|.\|.''.
.PP
The result
of the unary
.B
\(mi
.R
operator
is the negative of its operand.
The usual arithmetic conversions are performed.
The negative of an unsigned quantity is computed by
subtracting its value from
2\v'-0.5'\fIn\fR\^\v'0.5' where \fIn\fR\^ is the number of bits in
the corresponding signed type.
.sp
.tr ~~
There is no unary
.B
\(pl
.R
operator.
.PP
The result of the logical negation operator
.B
!
.R
is one if the value of its operand is zero, zero if the value of its
operand is nonzero.
The type of the result is
.B
int\fR.
.R
It is applicable to any arithmetic type
or to pointers.
.PP
The
.B
\s+2~\s0
.R
operator yields the one's complement of its operand.
The usual arithmetic conversions are performed.
The type of the operand must be integral.
.PP
The object referred to by the lvalue operand of prefix
.B
\(pl\(pl
.R
is incremented.
The value is the new value of the operand
but is not an lvalue.
The expression
.B
\(pl\(plx
.R
is equivalent to
\fBx=x\(pl1\fR.
See the discussions ``Additive Operators'' and ``Assignment
Operators'' for information on conversions.
.PP
The lvalue operand of prefix
.B
\(mi\(mi
.R
is decremented
analogously to the
prefix
.B
\(pl\(pl
.R
operator.
.PP
When postfix
.B
\(pl\(pl
.R
is applied to an lvalue,
the result is the value of the object referred to by the lvalue.
After the result is noted, the object
is incremented in the same
manner as for the prefix
.B
\(pl\(pl
.R
operator.
The type of the result is the same as the type of the lvalue expression.
.PP
When postfix
.B
\(mi\(mi
.R
is applied to an lvalue,
the result is the value of the object referred to by the lvalue.
After the result is noted, the object
is decremented in the manner as for the prefix
.B
\(mi\(mi
.R
operator.
The type of the result is the same as the type of the lvalue
expression.
.PP
An expression preceded by the parenthesized name of a data type
causes conversion of the value of the expression to the named type.
This construction is called a
.I
cast\fR.
.R
Type names are described in ``Type Names'' under ``Declarations.''
.PP
The
.B
sizeof
.R
operator yields the size
in bytes of its operand.
(A
.I
byte
.R
is undefined by the language
except in terms of the value of
.B
sizeof\fR.
.R
However, in all existing implementations,
a byte is the space required to hold a
\fBchar.\fR)
When applied to an array, the result is the total
number of bytes in the array.
The size is determined from
the declarations of
the objects in the expression.
This expression is semantically an
.B
unsigned
.R
constant and may
be used anywhere a constant is required.
Its major use is in communication with routines
like storage allocators and I/O systems.
.PP
The
.B
sizeof
.R
operator
may also be applied to a parenthesized type name.
In that case it yields the size in bytes of an object
of the indicated type.
.PP
The construction
\fBsizeof(\fItype\|\fR\^)\fR\^
is taken to be a unit,
so the expression
\fBsizeof(\fItype\|\fB)-2\fR
is the same as
\fB(sizeof(\fItype\|\fB))-2\fR.
.NH 2
Multiplicative Operators
.PP
The multiplicative operators
\fB\(**\fR,
\fB/\fR,
and
.B
%
.R
group left to right.
The usual arithmetic conversions are performed.
.DS
\fImultiplicative expression:
        expression \(** expression
        expression / expression
        expression % expression\fR
.DE
.PP
The binary
.B
\(**
.R
operator indicates multiplication.
The
.B
\(**
.R
operator is associative,
and expressions with several multiplications at the same
level may be rearranged by the compiler.
The binary
.B
/
.R
operator indicates division.
.PP
The binary
.B
%
.R
operator yields the remainder
from the division of the first expression by the second.
The operands must be integral.
.PP
When positive integers are divided, truncation is toward 0;
but the form of truncation is machine-dependent
if either operand is negative.
On all machines covered by this manual,
the remainder has the same sign as the dividend.
It is always true that
.B
(a/b)\(**b\ \(pl a%b
.R
is equal to
.B
a
.R
(if
.B
b
.R
is not 0).
.NH 2
Additive Operators
.PP
The additive operators
.B
\(pl
.R
and
.B
\(mi
.R
group left to right.
The usual arithmetic conversions are performed.
There are some additional type possibilities for each operator.
.DS
\fIadditive-expression:
        expression \(pl expression
        expression \(mi expression\fR
.DE
.PP
The result of the
.B
\(pl
.R
operator is the sum of the operands.
A pointer to an object in an array and
a value of any integral type
may be added.
The latter is in all cases converted to
an address offset
by multiplying it
by the length of the object to which the
pointer points.
The result is a pointer
of the same type as the original pointer
which points to another object in the same array,
appropriately offset from the original object.
Thus if
.B
P
.R
is a pointer
to an object in an array, the expression
.B
P\(pl1
.R
is a pointer
to the next object in the array.
No further type combinations are allowed for pointers.
.PP
The
.B
\(pl
.R
operator is associative,
and expressions with several additions at the same level may
be rearranged by the compiler.
.PP
The result of the
.B
\(mi
.R
operator is the difference of the operands.
The usual arithmetic conversions are performed.
Additionally,
a value of any integral type
may be subtracted from a pointer,
and then the same conversions for addition apply.
.PP
If two pointers to objects of the same type are subtracted,
the result is converted
(by division by the length of the object)
to an
.B
int
.R
representing the number of
objects separating
the pointed-to objects.
This conversion will in general give unexpected
results unless the pointers point
to objects in the same array, since pointers, even
to objects of the same type, do not necessarily differ
by a multiple of the object length.
.NH 2
Shift Operators
.PP
The shift operators
.B
<<
.R
and
.B
>>
.R
group left to right.
Both perform the usual arithmetic conversions on their operands,
each of which must be integral.
Then the right operand is converted to
\fBint\fR;
the type of the result is that of the left operand.
The result is undefined if the right operand is negative
or greater than or equal to the length of the object in bits.
On the VAX a negative right operand is interpreted as reversing
the direction of the shift.
.DS
\fIshift-expression:
        expression << expression
        expression >> expression\fR
.DE
.PP
The value of
.B
E1<<E2
.R
is
.B
E1
.R
(interpreted as a bit
pattern) left-shifted
.B
E2
.R
bits.
Vacated bits are 0 filled.
The value of
.B
E1>>E2
.R
is
.B
E1
.R
right-shifted
.B
E2
.R
bit positions.
The right shift is guaranteed to be logical
(0 fill)
if
.B
E1
.R
is
\fBunsigned\fR;
otherwise, it may be
arithmetic.
.NH 2
Relational Operators
.PP
The relational operators group left to right.
.DS
\fIrelational-expression:
        expression < expression
        expression > expression
        expression <= expression
        expression >= expression\fR
.DE
.PP
The operators
.B
<
.R
(less than),
.B
>
.R
(greater than), \fB<=\fR
(less than
or equal to), and
.B
>=
.R
(greater than or equal to)
all yield 0 if the specified relation is false
and 1 if it is true.
The type of the result is
.B
int\fR.
The usual arithmetic conversions are performed.
Two pointers may be compared;
the result depends on the relative locations in the address space
of the pointed-to objects.
Pointer comparison is portable only when the pointers point to objects
in the same array.
.NH 2
Equality Operators
.PP
.DS
\fIequality-expression:
        expression == expression
        expression != expression\fR
.DE
.PP
The
.B
==
.R
(equal to) and the
.B
!=
.R
(not equal to) operators
are exactly analogous to the relational
operators except for their lower
precedence.
(Thus
.B
a<b\ ==\ c<d
.R
is 1 whenever
.B
a<b
.R
and
.B
c<d
.R
have the same truth value).
.PP
A pointer may be compared to an integer
only if the
integer is the constant 0.
A pointer to which 0 has been assigned is guaranteed
not to point to any object
and will appear to be equal to 0.
In conventional usage, such a pointer is considered to be null.
.NH 2
Bitwise \s-1AND\s0 Operator
.PP
.DS
\fIand-expression:
        expression & expression\fR
.DE
.PP
The
.B
&
.R
operator is associative,
and expressions involving
.B
&
.R
may be rearranged.
The usual arithmetic conversions are performed.
The result is the bitwise
AND
function of the operands.
The operator applies only to integral
operands.
.NH 2
Bitwise Exclusive \s-1OR\s0 Operator
.DS
\fIexclusive-or-expression:
        expression ^ expression\fR
.DE
.PP
The
.B
^
.R
operator is associative,
and expressions involving
.B
^
.R
may be rearranged.
The usual arithmetic conversions are performed;
the result is
the bitwise exclusive
OR
function of
the operands.
The operator applies only to integral
operands.
.NH 2
Bitwise Inclusive \s-1OR\s0 Operator
.DS
\fIinclusive-or-expression:
        expression | expression\fR
.DE
.PP
The
.B
|
.R
operator is associative,
and expressions involving
.B
|
.R
may be rearranged.
The usual arithmetic conversions are performed;
the result is the bitwise inclusive
OR
function of its operands.
The operator applies only to integral
operands.
.NH 2
Logical \s-1AND\s0 Operator
.DS
\fIlogical-and-expression:
        expression && expression\fR
.DE
.PP
The
.B
&&
.R
operator groups left to right.
It returns 1 if both its operands
evaluate to nonzero, 0 otherwise.
Unlike
\fB&\fR,
.B
&&
.R
guarantees left to right
evaluation; moreover, the second operand is not evaluated
if the first operand is 0.
.PP
The operands need not have the same type, but each
must have one of the fundamental
types or be a pointer.
The result is always
.B
int\fR.
.R
.NH 2
Logical \s-1OR\s0 Operator
.DS
\fIlogical-or-expression:
        expression || expression\fR
.DE
.PP
The
.B
||
.R
operator groups left to right.
It returns 1 if either of its operands
evaluates to nonzero, 0 otherwise.
Unlike
\fB|\fR,
.B
||
.R
guarantees left to right evaluation; moreover,
the second operand is not evaluated
if the value of the first operand is nonzero.
.PP
The operands need not have the same type, but each
must
have one of the fundamental types
or be a pointer.
The result is always
.B
int\fR.
.R
.NH 2
Conditional Operator
.DS
\fIconditional-expression:
        expression ? expression : expression\fR
.DE
.PP
Conditional expressions group right to left.
The first expression is evaluated;
and if it is nonzero, the result is the value of the
second expression, otherwise that of third expression.
If possible, the usual arithmetic conversions are performed
to bring the second and third expressions to a common type.
If both are structures or unions of the same type,
the result has the type of the structure or union.
If both pointers are of the same type,
the result has the common type.
Otherwise, one must be a pointer and the other the constant 0,
and the result has the type of the pointer.
Only one of the second and third
expressions is evaluated.
.NH 2
Assignment Operators
.PP
There are a number of assignment operators,
all of which group right to left.
All require an lvalue as their left operand,
and the type of an assignment expression is that
of its left operand.
The value is the value stored in the
left operand after the assignment has taken place.
The two parts of a compound assignment operator are separate
tokens.
.DS
\fIassignment-expression:
        lvalue = expression
        lvalue \(pl= expression
        lvalue \(mi= expression
        lvalue \(**= expression
        lvalue /= expression
        lvalue %= expression
        lvalue >>= expression
        lvalue <<= expression
        lvalue &= expression
        lvalue ^= expression
        lvalue |= expression\fR
.DE
.PP
In the simple assignment with
\fB=\fR,
the value of the expression replaces that of the object
referred
to by the lvalue.
If both operands have arithmetic type,
the right operand is converted to the type of the left
preparatory to the assignment.
Second, both operands may be structures or unions of the same type.
Finally, if the left operand is a pointer, the right operand must in general be a pointer
of the same type.
However, the constant 0 may be assigned to a pointer;
it is guaranteed that this value will produce a null
pointer distinguishable from a pointer to any object.
.PP
The behavior of an expression
of the form
\fBE1\fR\^ \fIop\fR\^ = \fBE2\fR\^
may be inferred by
taking it as equivalent to
\fBE1 = E1 \fIop\fR\^ (\fBE2\fR\^);
however,
.B
E1
.R
is evaluated only once.
In
.B
\(pl=
.R
and
\fB\(mi=\fR,
the left operand may be a pointer; in which case, the (integral) right
operand is converted as explained
in ``Additive Operators.''
All right operands and all nonpointer left operands must
have arithmetic type.
.NH 2
Comma Operator
.DS
\fIcomma-expression:
        expression , expression\fR
.DE
.PP
A pair of expressions separated by a comma is evaluated
left to right, and the value of the left expression is
discarded.
The type and value of the result are the
type and value of the right operand.
This operator groups left to right.
In contexts where comma is given a special meaning,
e.g., in lists of actual arguments
to functions (see ``Primary Expressions'') and lists
of initializers (see ``Initialization'' under ``DECLARATIONS''),
the comma operator as described in this subpart
can only appear in parentheses. For example,
.DS
\fBf(a, (t=3, t\(pl2), c)\fR
.DE
.LP
has three arguments, the second of which has the value 5.
.NH 1
Declarations
.PP
Declarations are used to specify the interpretation
which C gives to each identifier; they do not necessarily
reserve storage associated with the identifier.
Declarations have the form
.DS
\fIdeclaration:
        decl-specifiers declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;\fR
.DE
.PP
The declarators in the declarator-list
contain the identifiers being declared.
The decl-specifiers
consist of a sequence of type and storage class specifiers.
.DS
\fIdecl-specifiers:
        type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
        sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'\fR
.DE
.PP
The list must be self-consistent in a way described below.
.NH 2
Storage Class Specifiers
.PP
The sc-specifiers are:
.DS
\fIsc-specifier:\fB
        auto
        static
        extern
        register
        typedef\fR
.DE
.PP
The
.B
typedef
.R
specifier does not reserve storage
and is called a ``storage class specifier'' only for syntactic convenience.
See ``Typedef'' for more information.
The meanings of the various storage classes were discussed in ``Names.''
.PP
The
\fBauto\fR,
\fBstatic\fR,
and
.B
register
.R
declarations also serve as definitions
in that they cause an appropriate amount of storage to be reserved.
In the
.B
extern
.R
case,
there must be an external definition (see ``External Definitions'')
for the given identifiers
somewhere outside the function in which they are declared.
.PP
A
.B
register
.R
declaration is best thought of as an
.B
auto
.R
declaration, together with a hint to the compiler
that the variables declared will be heavily used.
Only the first few
such declarations in each function are effective.
Moreover, only variables of certain types will be stored in registers;
on the
PDP-11,
they are
.B
int
.R
or pointer.
One other restriction applies to register variables:
the address-of operator
.B
&
.R
cannot be applied to them.
Smaller, faster programs can be expected if register declarations
are used appropriately,
but future improvements in code generation
may render them unnecessary.
.PP
At most, one sc-specifier may be given in a declaration.
If the sc-specifier is missing from a declaration, it
is taken to be
.B
auto
.R
inside a function,
.B
extern
.R
outside.
Exception:
functions are never
automatic.
.NH 2
Type Specifiers
.PP
The type-specifiers are
.DS
\fItype-specifier:
        struct-or-union-specifier
        typedef-name
        enum-specifier
basic-type-specifier:
        basic-type
        basic-type basic-type-specifiers
basic-type:\fB
        char
        short
        int
        long
        unsigned
        float
        double
        void\fR
.DE
.PP
At most one of the words \fBlong\fR or \fBshort\fR
may be specified in conjunction with \fBint\fR;
the meaning is the same as if \fBint\fR were not mentioned.
The word \fBlong\fR may be specified in conjunction with
\fBfloat\fR;
the meaning is the same as \fBdouble\fR.
The word \fBunsigned\fR may be specified alone, or
in conjunction with \fBint\fR or any of its short
or long varieties, or with \fBchar\fR.
.PP
Otherwise, at most on type-specifier may be
given in a declaration.
In particular, adjectival use of \fBlong\fR,
\fBshort\fR, or \fBunsigned\fR is not permitted
with \fBtypedef\fR names.
If the type-specifier is missing from a declaration,
it is taken to be \fBint\fR.
.PP
Specifiers for structures, unions, and enumerations are discussed in
``Structure, Union, and Enumeration Declarations.''
Declarations with
.B
typedef
.R
names are discussed in ``Typedef.''
.NH 2
Declarators
.PP
The declarator-list appearing in a declaration
is a comma-separated sequence of declarators,
each of which may have an initializer.
.DS
\fIdeclarator-list:
        init-declarator
        init-declarator , declarator-list
.DE
.DS
\fIinit-declarator:
        declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'\fR
.DE
.PP
Initializers are discussed in ``Initialization''.
The specifiers in the declaration
indicate the type and storage class of the objects to which the
declarators refer.
Declarators have the syntax:
.DS
\fIdeclarator:
        identifier
        ( declarator )
        \(** declarator
        declarator ()
        declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]\fR
.DE
.PP
The grouping is
the same as in expressions.
.NH 2
Meaning of Declarators
.PP
Each declarator is taken to be
an assertion that when a construction of
the same form as the declarator appears in an expression,
it yields an object of the indicated
type and storage class.
.PP
Each declarator contains exactly one identifier; it is this identifier that
is declared.
If an unadorned identifier appears
as a declarator, then it has the type
indicated by the specifier heading the declaration.
.PP
A declarator in parentheses is identical to the unadorned declarator,
but the binding of complex declarators may be altered by parentheses.
See the examples below.
.PP
Now imagine a declaration
.DS
\fBT D1\fR
.DE
.LP
where
.B
T
.R
is a type-specifier (like
\fBint\fR,
etc.)
and
.B
D1
.R
is a declarator.
Suppose this declaration makes the identifier have type
``\|.\|.\|.\|
.B
T
.R
,''
where the ``\|.\|.\|.\|'' is empty if
.B
D1
.R
is just a plain identifier
(so that the type of
.B
x
.R
in
\fB`int x''\fR
is just
\fBint\fR).
Then if
.B
D1
.R
has the form
.DS
\fB\(**D\fR
.DE
.LP
the type of the contained identifier is
``\|.\|.\|.\| pointer to
.B
T
.R
\&.''
.PP
If
.B
D1
.R
has the form
.DS
\fBD\|(\|\|)\|\fR
.DE
.LP
then the contained identifier has the type
``\|.\|.\|. function returning
\fBT\fR.''
.LP
If
.B
D1
.R
has the form
.DS
\fBD\|[\|\fIconstant-expression\fB\|]\fR
.DE
.LP
or
.DS
\fBD\|[\|]\|\fR
.DE
.LP
then the contained identifier has type
``\|.\|.\|.\| array of
\fBT\fR.''
In the first case, the constant
expression
is an expression
whose value is determinable at compile time
, whose type is
.B
int\fR,
and whose value is positive.
(Constant expressions are defined precisely in ``Constant Expressions.'')
When several ``array of'' specifications are adjacent, a multidimensional
array is created;
the constant expressions which specify the bounds
of the arrays may be missing only for the first member of the sequence.
This elision is useful when the array is external
and the actual definition, which allocates storage,
is given elsewhere.
The first constant expression may also be omitted
when the declarator is followed by initialization.
In this case the size is calculated from the number
of initial elements supplied.
.PP
An array may be constructed from one of the basic types, from a pointer,
from a structure or union,
or from another array (to generate a multidimensional array).
.PP
Not all the possibilities
allowed by the syntax above are actually
permitted.
The restrictions are as follows:
functions may not return
arrays or functions
although they may return pointers;
there are no arrays of functions although
there may be arrays of pointers to functions.
Likewise, a structure or union may not contain a function;
but it may contain a pointer to a function.
.PP
As an example, the declaration
.DS
\fBint i, \(**ip, f(), \(**fip(), (\(**pfi)();\fR
.DE
.LP
declares an integer
\fBi\fR,
a pointer
.B
ip
.R
to an integer,
a function
.B
f
.R
returning an integer,
a function
.B
fip
.R
returning a pointer to an integer,
and a pointer
.B
pfi
.R
to a function which
returns an integer.
It is especially useful to compare the last two.
The binding of
.B
\(**fip()
.R
is
.B
\(**(fip())\fR.
.R
The declaration suggests,
and the same construction in an expression
requires, the calling of a function
.B
fip\fR.
.R
Using indirection through the (pointer) result
to yield an integer.
In the declarator
\fB(\(**pfi)()\fR,
the extra parentheses are necessary, as they are also
in an expression, to indicate that indirection through
a pointer to a function yields a function, which is then called;
it returns an integer.
.PP
As another example,
.DS
\fBfloat fa[17], \(**afp[17];\fR
.DE
.LP
declares an array of
.B
float
.R
numbers and an array of
pointers to
.B
float
.R
numbers.
Finally,
.DS
\fBstatic int x3d[3][5][7];\fR
.DE
.LP
declares a static 3-dimensional array of integers,
with rank 3\(mu5\(mu7.
In complete detail,
.B
x3d
.R
is an array of three items;
each item is an array of five arrays;
each of the latter arrays is an array of seven
integers.
Any of the expressions
\fBx3d\fR,
\fBx3d[i]\fR,
\fBx3d[i][j]\fR,
.B
x3d[i][j][k]
.R
may reasonably appear in an expression.
The first three have type ``array''
and the last has type
.B
int\fR.
.R
.NH 2
Structure and Union Declarations
.PP
A structure
is an object consisting of a sequence of named members.
Each member may have any type.
A union is an object which may, at a given time, contain any one
of several members.
Structure and union specifiers have the same form.
.DS
\fIstruct-or-union-specifier:
        struct-or-union { struct-decl-list }
        struct-or-union identifier { struct-decl-list }
        struct-or-union identifier
.DE
.DS
\fIstruct-or-union:\fB
        struct
        union\fR
.DE
.PP
The
struct-decl-list
.ne 4
is a sequence of declarations for the members of the structure or union:
.DS
\fIstruct-decl-list:
        struct-declaration
        struct-declaration struct-decl-list
.DE
.DS
\fIstruct-declaration:
        type-specifier struct-declarator-list ;
.DE
.DS
\fIstruct-declarator-list:
        struct-declarator
        struct-declarator , struct-declarator-list\fR
.DE
.PP
In the usual case, a struct-declarator is just a declarator
for a member of a structure or union.
A structure member may also consist of a specified number of bits.
Such a member is also called a
.I
field ;
.R
its length,
a non-negative constant expression,
is set off from the field name by a colon.
.DS
\fIstruct-declarator:
        declarator
        declarator : constant-expression
        : constant-expression\fR
.DE
.PP
Within a structure, the objects declared
have addresses which increase as the declarations
are read left to right.
Each nonfield member of a structure
begins on an addressing boundary appropriate
to its type;
therefore, there may
be unnamed holes in a structure.
Field members are packed into machine integers;
they do not straddle words.
A field which does not fit into the space remaining in a word
is put into the next word.
No field may be wider than a word.
.PP
Fields are assigned right to left
on the
PDP-11
and
VAX-11,
left to right on the 3B 20.
.PP
A struct-declarator with no declarator, only a colon and a width,
indicates an unnamed field useful for padding to conform
to externally-imposed layouts.
As a special case, a field with a width of 0
specifies alignment of the next field at an implementation dependent boundary.
.PP
The language does not restrict the types of things that
are declared as fields,
but implementations are not required to support any but
integer fields.
Moreover,
even
.B
int
.R
fields may be considered to be unsigned.
On the
PDP-11,
fields are not signed and have only integer values;
on the
VAX-11,
fields declared with
.B
int
.R
are treated as containing a sign.
For these reasons,
it is strongly recommended that fields be declared as
.B
unsigned\fR.
.R
In all implementations,
there are no arrays of fields,
and the address-of operator
.B
&
.R
may not be applied to them, so that there are no pointers to
fields.
.PP
A union may be thought of as a structure all of whose members
begin at offset 0 and whose size is sufficient to contain
any of its members.
At most, one of the members can be stored in a union
at any time.
.PP
A structure or union specifier of the second form, that is, one of
.DS
        \fBstruct \fIidentifier { struct-decl-list \fR}
        \fBunion \fIidentifier { struct-decl-list \fR}
.DE
.LP
declares the identifier to be the
.I
structure tag
.R
(or union tag)
of the structure specified by the list.
A subsequent declaration may then use
the third form of specifier, one of
.DS
        \fBstruct \fIidentifier\fR
        \fBunion \fIidentifier\fR
.DE
.PP
Structure tags allow definition of self-referential
structures. Structure tags also
permit the long part of the declaration to be
given once and used several times.
It is illegal to declare a structure or union
which contains an instance of
itself, but a structure or union may contain a pointer to an instance of itself.
.PP
The third form of a structure or union specifier may be
used prior to a declaration which gives the complete specification
of the structure or union in situations in which the size
of the structure or union is unnecessary.
The size is unnecessary in two situations: when a
pointer to a structure or union is being declared and
when a \fBtypedef\fR name is declared to be a synonym
for a structure or union.
This, for example, allows the declaration of a pair
of structures which contain pointers to each other.
.PP
The names of members and tags do not conflict
with each other or with ordinary variables.
A particular name may not be used twice
in the same structure,
but the same name may be used in several different structures in the same scope.
.PP
A simple but important example of a structure declaration is
the following binary tree structure:
.DS
\fBstruct tnode
{
        char tword[20];
        int count;
        struct tnode \(**left;
        struct tnode \(**right;
};\fR
.DE
.LP
which contains an array of 20 characters, an integer, and two pointers
to similar structures.
Once this declaration has been given, the
declaration
.DS
\fBstruct tnode s, \(**sp;\fR
.DE
.LP
declares
.B
s
.R
to be a structure of the given sort
and
.B
sp
.R
to be a pointer to a structure
of the given sort.
With these declarations, the expression
.DS
\fBsp->count\fR
.DE
.LP
refers to the
.B
count
.R
field of the structure to which
.B
sp
.R
points;
.DS
\fBs.left\fR
.DE
.LP
refers to the left subtree pointer
of the structure
\fBs\fR;
and
.DS
\fBs.right->tword[0]\fR
.DE
.LP
refers to the first character of the
.B
tword
.R
member of the right subtree of
.B
s\fR.
.R
.PP
.NH 2
Enumeration Declarations
.PP
Enumeration variables and constants have integral type.
.DS
\fIenum-specifier:\fB
        enum\fI { enum-list \fR}\fB
        enum \fIidentifier { enum-list \fR}\fB
        enum \fIidentifier
.sp
enum-list:
        enumerator
        enum-list , enumerator
.sp
enumerator:
        identifier
        identifier = constant-expression\fR
.DE
.PP
The identifiers in an enum-list are declared as constants
and may appear wherever constants are required.
If no enumerators with
.B
=
.R
appear, then the values of the
corresponding constants begin at 0 and increase by 1 as the declaration is
read from left to right.
An enumerator with
.B
=
.R
gives the associated identifier the value
indicated; subsequent identifiers continue the progression from the assigned value.
.PP
The names of enumerators in the same scope must all be distinct
from each other and from those of ordinary variables.
.PP
The role of the identifier in the enum-specifier
is entirely analogous to that of the structure tag
in a struct-specifier; it names a particular enumeration.
For example,
.DS L
\fBenum color { chartreuse, burgundy, claret=20, winedark };
\&...
enum color *cp, col;
\&...
col = claret;
cp = &col;
\&...
if (*cp == burgundy) ...\fR
.DE
.LP
makes
.B
color
.R
the enumeration-tag of a type describing various colors,
and then declares
.B
cp
.R
as a pointer to an object of that type,
and
.B
col
.R
as an object of that type.
The possible values are drawn from the set {0,1,20,21}.
.NH 2
Initialization
.PP
A declarator may specify an initial value for the
identifier being declared.
The initializer is preceded by
.B
=
.R
and
consists of an expression or a list of values nested in braces.
.DS
\fIinitializer:
        = expression
        = { initializer-list }
        = { initializer-list , }
.DE
.DS
\fIinitializer-list:
        expression
        initializer-list , initializer-list\fR
        { \fIinitializer-list \fR}
        { \fIinitializer-list\fR , }
.DE
.PP
All the expressions in an initializer
for a static or external variable must be constant
expressions, which are described in ``CONSTANT EXPRESSIONS'',
or expressions which reduce to the address of a previously
declared variable, possibly offset by a constant expression.
Automatic or register variables may be initialized by arbitrary
expressions involving constants and previously declared variables and functions.
.PP
Static and external variables that are not initialized are
guaranteed to start off as zero.
Automatic and register variables that are not initialized
are guaranteed to start off as garbage.
.PP
When an initializer applies to a
.I
scalar
.R
(a pointer or an object of arithmetic type),
it consists of a single expression, perhaps in braces.
The initial value of the object is taken from
the expression; the same conversions as for assignment are performed.
.PP
When the declared variable is an
.I
aggregate
.R
(a structure or array),
the initializer consists of a brace-enclosed, comma-separated list of
initializers for the members of the aggregate
written in increasing subscript or member order.
If the aggregate contains subaggregates, this rule
applies recursively to the members of the aggregate.
If there are fewer initializers in the list than there are members of the aggregate,
then the aggregate is padded with zeros.
It is not permitted to initialize unions or automatic aggregates.
.PP
Braces may in some cases be omitted.
If the initializer begins with a left brace, then
the succeeding comma-separated list of initializers initializes
the members of the aggregate;
it is erroneous for there to be more initializers than members.
If, however, the initializer does not begin with a left brace,
then only enough elements from the list are taken to account
for the members of the aggregate; any remaining members
are left to initialize the next member of the aggregate of which
the current aggregate is a part.
.PP
A final abbreviation allows a
.B
char
.R
array to be initialized by a string.
In this case successive characters of the string
initialize the members of the array.
.PP
For example,
.DS
\fBint x[] = { 1, 3, 5 };\fR
.DE
.LP
declares and initializes
.B
x
.R
as a one-dimensional array which has three members, since no size was specified
and there are three initializers.
.DS
\fBfloat y[4][3] =
{
        { 1, 3, 5 },
        { 2, 4, 6 },
        { 3, 5, 7 },
};\fR
.DE
.LP
is a completely-bracketed initialization:
1, 3, and 5 initialize the first row of
the array
\fBy[0]\fR,
namely
\fBy[0][0]\fR,
\fBy[0][1]\fR,
and
.B
y[0][2]\fR.
.R
Likewise, the next two lines initialize
.B
y[1]
.R
and
.B
y[2]\fR.
.R
The initializer ends early and therefore
.B
y[3]
.R
is initialized with 0.
Precisely, the same effect could have been achieved by
.DS
\fBfloat y[4][3] =
{
        1, 3, 5, 2, 4, 6, 3, 5, 7
};\fR
.DE
.PP
The initializer for
.B
y
.R
begins with a left brace but that for
.B
y[0]
.R
does not;
therefore, three elements from the list are used.
Likewise, the next three are taken successively for
.B
y[1]
.R
and
.B
y[2]\fR.
.R
Also,
.DS
\fBfloat y[4][3] =
{
        { 1 }, { 2 }, { 3 }, { 4 }
};\fR
.DE
.LP
initializes the first column of
.B
y
.R
(regarded as a two-dimensional array)
and leaves the rest 0.
.PP
Finally,
.DS
\fBchar msg[] = "Syntax error on line %s\en";\fR
.DE
.LP
shows a character array whose members are initialized
with a string.
.NH 2
Type Names
.PP
In two contexts (to specify type conversions explicitly
by means of a cast
and as an argument of
\fBsizeof\fR),
it is desired to supply the name of a data type.
This is accomplished using a ``type name'', which in essence
is a declaration for an object of that type which omits the name of
the object.
.DS
\fItype-name:
        type-specifier abstract-declarator
.DE
.DS
\fIabstract-declarator:
        empty
        ( abstract-declarator )
        \(** abstract-declarator
        abstract-declarator ()
        abstract-declarator\fR\^ [ \fIconstant-expression\v'0.5'\s-2opt\s0\v'-0.5' \fR\^]
.DE
.PP
To avoid ambiguity,
in the construction
.DS
        \fI( abstract-declarator \fR)
.DE
.LP
the
abstract-declarator
is required to be nonempty.
Under this restriction,
it is possible to identify uniquely the location in the abstract-declarator
where the identifier would appear if the construction were a declarator
in a declaration.
The named type is then the same as the type of the
hypothetical identifier.
For example,
.DS
\fBint
int \(**
int \(**[3]
int (\(**)[3]
int \(**()
int (\(**)()
int (\(**[3])()\fR
.DE
.LP
name respectively the types ``integer,'' ``pointer to integer,''
``array of three pointers to integers,''
``pointer to an array of three integers,''
``function returning pointer to integer,''
``pointer to function returning an integer,''
and ``array of three pointers to functions returning an integer.''
.NH 2
Typedef
.PP
Declarations whose ``storage class'' is
.B
typedef
.R
do not define storage but instead
define identifiers which can be used later
as if they were type keywords naming fundamental
or derived types.
.DS
\fItypedef-name:\fR
        \fIidentifier\fR
.DE
.PP
Within the scope of a declaration involving
\fBtypedef\fR,
each identifier appearing as part of
any declarator therein becomes syntactically
equivalent to the type keyword
naming the type
associated with the identifier
in the way described in ``Meaning of Declarators.''
For example,
after
.DS
\fBtypedef int MILES, \(**KLICKSP;
typedef struct { double re, im; } complex;\fR
.DE
.LP
the constructions
.DS
\fBMILES distance;
extern KLICKSP metricp;
complex z, \(**zp;\fR
.DE
.LP
are all legal declarations; the type of
.B
distance
.R
is
\fBint\fR,
that of
.B
metricp
.R
is ``pointer to \fBint\fR, ''
and that of
.B
z
.R
is the specified structure.
The
.B
zp
.R
is a pointer to such a structure.
.PP
The
.B
typedef
.R
does not introduce brand-new types, only synonyms for
types which could be specified in another way.
Thus
in the example above
.B
distance
.R
is considered to have exactly the same type as
any other
.B
int
.R
object.
.NH 1
Statements
.PP
Except as indicated, statements are executed in sequence.
.NH 2
Expression Statement
.PP
Most statements are expression statements, which have
the form
.DS
\fIexpression \fR;
.DE
.PP
Usually expression statements are assignments or function
calls.
.NH 2
Compound Statement or Block
.PP
So that several statements can be used where one is expected,
the compound statement (also, and equivalently, called ``block'') is provided:
.DS
\fIcompound-statement:
        { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
.DE
.DS
\fIdeclaration-list:
        declaration
        declaration declaration-list
.DE
.DS
\fIstatement-list:
        statement
        statement statement-list\fR
.DE
.PP
If any of the identifiers
in the declaration-list were previously declared,
the outer declaration is pushed down for the duration of the block,
after which it resumes its force.
.PP
Any initializations of
.B
auto
.R
or
.B
register
.R
variables are performed each time the block is entered at the top.
It is currently possible
(but a bad practice)
to transfer into a block;
in that case the initializations are not performed.
Initializations of
.B
static
.R
variables are performed only once when the program
begins execution.
Inside a block,
.B
extern
.R
declarations do not reserve storage
so initialization is not permitted.
.NH 2
Conditional Statement
.PP
The two forms of the conditional statement are
.DS
\fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
\fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement \fBelse \fIstatement\fR\^
.DE
.PP
In both cases, the expression is evaluated;
and if it is nonzero, the first substatement
is executed.
In the second case, the second substatement is executed
if the expression is 0.
The ``else'' ambiguity is resolved by connecting
an
.B
else
.R
with the last encountered
\fBelse\fR-less
.B
if\fR.
.R
.NH 2
While Statement
.PP
The
.B
while
.R
statement has the form
.DS
\fBwhile\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
.DE
.PP
The substatement is executed repeatedly
so long as the value of the
expression remains nonzero.
The test takes place before each execution of the
statement.
.NH 2
Do Statement
.PP
The
.B
do
.R
statement has the form
.DS
\fBdo \fIstatement  \fBwhile\fR\^ ( \fIexpression \fR\^) ;
.DE
.PP
The substatement is executed repeatedly until
the value of the expression becomes 0.
The test takes place after each execution of the
statement.
.NH 2
For Statement
.PP
The
.B
for
.R
statement has the form:
.DS
\fBfor\fI ( exp-1\v'0.5'\s-2opt\s0\v'-0.5' ; exp-2\v'0.5'\s-2opt\s0\v'-0.5' ; exp-3\v'0.5'\s-2opt\s0\v'-0.5' ) statement\fR
.DE
.PP
.sp
Except for the behavior of \fBcontinue\fR,
this statement is equivalent to
.DS
\fIexp-1 \fR;
\fBwhile\fR\^ ( \fIexp-2\ ) \fR\^
{
        \fIstatement
        exp-3 ;\fR
}
.DE
.PP
Thus the first expression specifies initialization
for the loop; the second specifies
a test, made before each iteration, such
that the loop is exited when the expression becomes
0.
The third expression often specifies an incrementing
that is performed after each iteration.
.PP
Any or all of the expressions may be dropped.
A missing
.I
exp-2
.R
makes the
implied
.B
while
.R
clause equivalent to
\fBwhile(1)\fR;
other missing expressions are simply
dropped from the expansion above.
.NH 2
Switch Statement
.PP
The
.B
switch
.R
statement causes control to be transferred
to one of several statements depending on
the value of an expression.
It has the form
.DS
\fBswitch\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
.DE
.PP
The usual arithmetic conversion is performed on the
expression, but the result must be
.B
int\fR.
.R
The statement is typically compound.
Any statement within the statement
may be labeled with one or more case prefixes
as follows:
.DS
\fBcase \fIconstant-expression \fR:
.DE
.LP
where the constant
expression
must be
.B
int\fR.
.R
No two of the case constants in the same switch
may have the same value.
Constant expressions are precisely defined in ``CONSTANT EXPRESSIONS.''
.PP
There may also be at most one statement prefix of the
form
.DS
\fBdefault :\fR
.DE
.PP
When the
.B
switch
.R
statement is executed, its expression
is evaluated and compared with each case constant.
If one of the case constants is
equal to the value of the expression,
control is passed to the statement
following the matched case prefix.
If no case constant matches the expression
and if there is a
\fBdefault\fR,
prefix, control
passes to the prefixed
statement.
If no case matches and if there is no
\fBdefault\fR,
then
none of the statements in the
switch is executed.
.PP
The prefixes
.B
case
.R
and
.B
default
.R
do not alter the flow of control,
which continues unimpeded across such prefixes.
To exit from a switch, see
``Break Statement.''
.PP
Usually, the statement that is the subject of a switch is compound.
Declarations may appear at the head of this
statement,
but
initializations of automatic or register variables
are ineffective.
.NH 2
Break Statement
.PP
The statement
.DS
\fBbreak ;\fR
.DE
.LP
causes termination of the smallest enclosing
\fBwhile\fR,
\fBdo\fR,
\fBfor\fR,
or
\fBswitch\fR
statement;
control passes to the
statement following the terminated statement.
.NH 2
Continue Statement
.PP
The statement
.DS
\fBcontinue ;\fR
.DE
.LP
causes control to pass to the loop-continuation portion of the
smallest enclosing
\fBwhile\fR,
\fBdo\fR,
or
\fBfor\fR
statement; that is to the end of the loop.
More precisely, in each of the statements
.DS
.TS
lw(2i) lw(2i) lw(2i).
\fBwhile (\|.\|.\|.\|) {	do {	for (\|.\|.\|.\|) {\fR
     \fIstatement ;	     statement ;	     statement ;\fR
     \fBcontin: ;	     contin: ;	     contin: ;
}	} while (...);	}\fR
.TE
.DE
.LP
a
.B
continue
.R
is equivalent to
.B
goto\ contin\fR.
.R
(Following the
.B
contin:
.R
is a null statement, see ``Null Statement''.)
.NH 2
Return Statement
.PP
A function returns to its caller by means of
the
.B
return
.R
statement which has one of the
forms
.DS
\fBreturn ;
return \fIexpression \fR;
.DE
.PP
In the first case, the returned value is undefined.
In the second case, the value of the expression
is returned to the caller
of the function.
If required, the expression is converted,
as if by assignment, to the type of
function in which it appears.
Flowing off the end of a function is
equivalent to a return with no returned value.
The expression may be parenthesized.
.NH 2
Goto Statement
.PP
Control may be transferred unconditionally by means of
the statement
.DS
\fBgoto \fIidentifier \fR;
.DE
.PP
The identifier must be a label
(see ``Labeled Statement'')
located in the current function.
.NH 2
Labeled Statement
.PP
Any statement may be preceded by
label prefixes of the form
.DS
\fIidentifier \fR:
.DE
.LP
which serve to declare the identifier
as a label.
The only use of a label is as a target of a
.B
goto\fR.
.R
The scope of a label is the current function,
excluding any subblocks in which the same identifier has been redeclared.
See ``SCOPE RULES.''
.NH 2
Null Statement
.PP
The null statement has the form
.DS
	\fB;\fR
.DE
.PP
A null statement is useful to carry a label just before the
.B
}
.R
of a compound statement or to supply a null
body to a looping statement such as
.B
while\fR.
.R
.NH 1
External Definitions
.PP
A C program consists of a sequence of external definitions.
An external definition declares an identifier to
have storage class
.B
extern
.R
(by default)
or perhaps
\fBstatic\fR,
and
a specified type.
The type-specifier (see ``Type Specifiers'' in
``DECLARATIONS'') may also be empty, in which
case the type is taken to be
.B
int\fR.
.R
The scope of external definitions persists to the end
of the file in which they are declared just as the effect
of declarations persists to the end of a block.
The syntax of external definitions is the same
as that of all declarations except that
only at this level may the code for functions be given.
.NH 2
External Function Definitions
.PP
Function definitions have the form
.DS
\fIfunction-definition:
        decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body\fR
.DE
.PP
The only sc-specifiers
allowed
among the decl-specifiers
are
.B
extern
.R
or
\fBstatic\fR;
see ``Scope of Externals'' in
``SCOPE RULES'' for the distinction between them.
A function declarator is similar to a declarator
for a ``function returning .\|.\|.\|'' except that
it lists the formal parameters of
the function being defined.
.DS
\fIfunction-declarator:
        declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
.DE
.DS
\fIparameter-list:
        identifier
        identifier , parameter-list\fR
.DE
.PP
The function-body
has the form
.DS
\fIfunction-body:
        declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement\fR
.DE
.PP
The identifiers in the parameter list, and only those identifiers,
may be declared in the declaration list.
Any identifiers whose type is not given are taken to be
.B
int\fR.
.R
The only storage class which may be specified is
\fBregister\fR;
if it is specified, the corresponding actual parameter
will be copied, if possible, into a register
at the outset of the function.
.PP
A simple example of a complete function definition is
.DS
\fBint max(a, b, c)
        int a, b, c;
{
        int m;
.sp
        m = (a > b) ? a : b;
        return((m > c) ? m : c);
}\fR
.DE
.PP
Here
.B
int
.R
is the type-specifier;
.B
max(a,\ b,\ c)
.R
is the function-declarator;
.B
int\ a,\ b,\ c;
.R
is the declaration-list for
the formal
parameters;
\fB{\ ...\ }\fR
is the
block giving the code for the statement.
.PP
The C program converts all
.B
float
.R
actual parameters
to
\fBdouble\fR,
so formal parameters declared
.B
float
.R
have their declaration adjusted to read
.B
double\fR.
.R
All \fBchar\fR and \fBshort\fR formal parameter
declarations are similarly adjusted
to read \fBint\fR.
Also, since a reference to an array in any context
(in particular as an actual parameter)
is taken to mean
a pointer to the first element of the array,
declarations of formal parameters declared ``array of .\|.\|.\|''
are adjusted to read ``pointer to .\|.\|.\|.''
.NH 2
External Data Definitions
.PP
An external data definition has the form
.DS
\fIdata-definition:
        declaration\fR
.DE
.PP
The storage class of such data may be
.B
extern
.R
(which is the default)
or
.B
static
.R
but not
.B
auto
.R
or
\fBregister\fR.
.NH 1
Scope Rules
.PP
A C program need not all
be compiled at the same time. The source text of the
program
may be kept in several files, and precompiled
routines may be loaded from
libraries.
Communication among the functions of a program
may be carried out both through explicit calls
and through manipulation of external data.
.PP
Therefore, there are two kinds of scopes to consider:
first, what may be called the
.UL lexical
.UL scope
of an identifier, which is essentially the
region of a program during which it may
be used without drawing ``undefined identifier''
diagnostics;
and second, the scope
associated with external identifiers,
which is characterized by the rule
that references to the same external
identifier are references to the same object.
.NH 2
Lexical Scope
.PP
The lexical scope of identifiers declared in external definitions
persists from the definition through
the end of the source file
in which they appear.
The lexical scope of identifiers which are formal parameters
persists through the function with which they are
associated.
The lexical scope of identifiers declared at the head of a block
persists until the end of the block.
The lexical scope of labels is the whole of the
function in which they appear.
.PP
In all cases, however,
if an identifier is explicitly declared at the head of a block,
including the block constituting a function,
any declaration of that identifier outside the block
is suspended until the end of the block.
.PP
Remember also (see ``Structure, Union, and Enumeration Declarations'' in
``DECLARATIONS'') that tags, identifiers associated with
ordinary variables,
and identities associated with structure and union members
form three disjoint classes
which do not conflict.
Members and tags follow the same scope rules
as other identifiers.
The \fBenum\fR constants are in the same
class as ordinary variables and follow the same scope rules.
The
.B
typedef
.R
names are in the same class as ordinary identifiers.
They may be redeclared in inner blocks, but an explicit
type must be given in the inner declaration:
.DS
\fBtypedef float distance;
\&...
{
     auto int distance;
     ...\fR
}
.DE
.PP
The
.B
int
.R
must be present in the second declaration,
or it would be taken to be
a declaration with no declarators and type
.B
distance\fR.
.R
.NH 2
Scope of Externals
.PP
If a function refers to an identifier declared to be
\fBextern\fR,
then somewhere among the files or libraries
constituting the complete program
there must be at least one external definition
for the identifier.
All functions in a given program which refer to the same
external identifier refer to the same object,
so care must be taken that the type and size
specified in the definition
are compatible with those specified
by each function which references the data.
.PP
It is illegal to explicitly initialize any external
identifier more than once in the set of files and libraries
comprising a multi-file program.
It is legal to have more than one data definition
for any external non-function identifier;
explicit use of \fBextern\fR does not
change the meaning of an external declaration.
.PP
In restricted environments, the use of the \fBextern\fR
storage class takes on an additional meaning.
In these environments, the explicit appearance of the
\fBextern\fR keyword in external data declarations of
identities without initialization indicates that
the storage for the identifiers is allocated elsewhere,
either in this file or another file.
It is required that there be exactly one definition of
each external identifier (without \fBextern\fR)
in the set of files and libraries
comprising a mult-file program.
.PP
Identifiers declared
.B
static
.R
at the top level in external definitions
are not visible in other files.
Functions may be declared
.B
static\fR.
.R
.nr Hu 1
.NH 1
Compiler Control Lines
.PP
The C compiler contains a preprocessor capable
of macro substitution, conditional compilation,
and inclusion of named files.
Lines beginning with
.B
#
.R
communicate
with this preprocessor.
There may be any number of blanks and horizontal tabs
between the \fB#\fR and the directive.
These lines have syntax independent of the rest of the language;
they may appear anywhere and have effect which lasts (independent of
scope) until the end of the source program file.
.nr Hu 1
.NH 2
Token Replacement
.PP
A compiler-control line of the form
.DS
\fB#define \fIidentifier token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
.DE
.LP
causes the preprocessor to replace subsequent instances
of the identifier with the given string of tokens.
Semicolons in or at the end of the token-string are part of that string.
A line of the form
.DS
\fB#define \fIidentifier(identifier, ... )token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
.DE
.LP
where there is no space between the first identifier
and the
\fB(\fR,
is a macro definition with arguments.
There may be zero or more formal parameters.
Subsequent instances of the first identifier followed
by a
\fB(\fR,
a sequence of tokens delimited by commas, and a
\fB)\fR
are replaced
by the token string in the definition.
Each occurrence of an identifier mentioned in the formal parameter list
of the definition is replaced by the corresponding token string from the call.
The actual arguments in the call are token strings separated by commas;
however, commas in quoted strings or protected by
parentheses do not separate arguments.
The number of formal and actual parameters must be the same.
Strings and character constants in the token-string are scanned
for formal parameters, but
strings and character constants in the rest of the program are
not scanned for defined identifiers
to replacement.
.PP
In both forms the replacement string is rescanned for more
defined identifiers.
In both forms
a long definition may be continued on another line
by writing
.B
\e
.R
at the end of the line to be continued.
.PP
This facility is most valuable for definition of ``manifest constants,''
as in
.DS
\fB#define TABSIZE 100
.sp
int table\|[\|TABSIZE\|]\|;\fR
.DE
.PP
A control line of the form
.DS
\fB#undef \fIidentifier\fR
.DE
.LP
causes the
identifier's preprocessor definition (if any) to be forgotten.
.PP
If a \fB#define\fRd identifier is the subject of a subsequent
\fB#define\fR with no intervening \fB#undef\fR, then
the two token-strings are compared textually.
If the two token-strings are not identical
(all white space is considered as equivalent), then
the identifier is considered to be redefined.
.nr Hu 1
.NH 2
File Inclusion
.PP
A compiler control line of
the form
.DS
\fB#include\fI "filename\|\fR"
.DE
.LP
causes the replacement of that
line by the entire contents of the file
.I
filename\fR.
.R
The named file is searched for first in the directory
of the file containing the \fB#include\fR,
and then in a sequence of specified or standard places.
Alternatively, a control line of the form
.DS
\fB#include\fI <filename\|\fR>
.DE
.LP
searches only the specified or standard places
and not the directory of the \fB#include\fR.
(How the places are specified is not part of the language.)
.PP
\fB#include\fRs
may be nested.
.nr Hu 1
.NH 2
Conditional Compilation
.PP
A compiler control line of the form
.DS
\fB#if \fIrestricted-constant-expression\fR
.DE
.LP
checks whether the restricted-constant expression evaluates to nonzero.
(Constant expressions are discussed in ``CONSTANT EXPRESSIONS'';
the following additional restrictions apply here:
the constant expression may not contain
.B
sizeof
.R
casts, or an enumeration constant.)
.PP
A restricted constant expression may also contain the
additional unary expression
.PP
\fBdefined \fIidentifier\fR
.LP
or
.PP
\fBdefined( \fIidentifier )\fR
.LP
which evaluates to one if the identifier is currently
defined in the preprocessor and zero if it is not.
.PP
All currently defined identifiers in restricted-constant-expressions
are replaced by their token-strings (except those identifiers
modified by \fBdefined\fR) just as in normal text.
The restricted constant expression will be evaluated only
after all expressions have finished.
During this evaluation, all undefined (to the procedure)
identifiers evaluate to zero.
.PP
A control line of the form
.DS
\fB#ifdef \fIidentifier\fR
.DE
.LP
checks whether the identifier is currently defined
in the preprocessor; i.e., whether it has been the
subject of a
.B
#define
.R
control line.
It is equivalent to \fB#ifdef(\fIidentifier\fB)\fR.
A control line of the form
.DS
\fB#ifndef \fIidentifier\fR
.DE
.LP
checks whether the identifier is currently undefined
in the preprocessor.
It is equivalent to
.DS
\fB#if	!\|defined(\fIidentifier\fB)\fR.
.DE
.PP
All three forms are followed by an arbitrary number of lines,
possibly containing a control line
.DS
\fB#else\fR
.DE
.LP
and then by a control line
.DS
\fB#endif\fR
.DE
.PP
If the checked condition is true,
then any lines
between
.B
#else
.R
and
.B
#endif
.R
are ignored.
If the checked condition is false, then any lines between
the test and a
.B
#else
.R
or, lacking a
\fB#else\fR,
the
.B
#endif
.R
are ignored.
.PP
These constructions may be nested.
.nr Hu 1
.NH 2
Line Control
.PP
For the benefit of other preprocessors which generate C programs,
a line of the form
.DS
\fB#line \fIconstant "filename\fR"
.DE
.LP
causes the compiler to believe, for purposes of error
diagnostics,
that the line number of the next source line is given by the constant and the current input
file is named by "\fIfilename\fR".
If "\fIfilename\fR" is absent, the remembered file name does not change.
.nr Hu 1
.NH 1
Implicit Declarations
.PP
It is not always necessary to specify
both the storage class and the type
of identifiers in a declaration.
The storage class is supplied by
the context in external definitions
and in declarations of formal parameters
and structure members.
In a declaration inside a function,
if a storage class but no type
is given, the identifier is assumed
to be
\fBint\fR;
if a type but no storage class is indicated,
the identifier is assumed to
be
.B
auto\fR.
.R
An exception to the latter rule is made for
functions because
.B
auto
.R
functions do not exist.
If the type of an identifier is ``function returning .\|.\|.\|,''
it is implicitly declared to be
.B
extern\fR.
.R
.PP
In an expression, an identifier
followed by
.B
(
.R
and not already declared
is contextually
declared to be ``function returning
.B
int\fR.''
.nr Hu 1
.NH 1
Types Revisited
.PP
This part summarizes the operations
which can be performed on objects of certain types.
.nr Hu 1
.NH 2
Structures and Unions
.PP
Structures and unions may be assigned, passed as arguments to functions,
and returned by functions.
Other plausible operators, such as equality comparison
and structure casts,
are not implemented.
.PP
In a reference
to a structure or union member, the
name on the right
of the \fB->\fR or the \fB.\fR
must specify a member of the aggregate
named or pointed to by the expression
on the left.
In general, a member of a union may not be inspected
unless the value of the union has been assigned using that same member.
However, one special guarantee is made by the language in order
to simplify the use of unions:
if a union contains several structures that share a common initial sequence
and if the union currently contains one of these structures,
it is permitted to inspect the common initial part of any of
the contained structures.
For example, the following is a legal fragment:
.DS
\fBunion
{
        struct
        {
                int        type;
        } n;
        struct
        {
                int        type;
                int        intnode;
        } ni;
        struct
        {
                int        type;
                float      floatnode;
        } nf;
} u;
\&...
u.nf.type = FLOAT;
u.nf.floatnode = 3.14;
\&...
if (u.n.type == FLOAT)
        ... sin(u.nf.floatnode) ...\fR
.DE
.PP
.nr Hu 1
.NH 2
Functions
.PP
There are only two things that
can be done with a function \fBm\fR,
call it or take its address.
If the name of a function appears in an
expression not in the function-name position of a call,
a pointer to the function is generated.
Thus, to pass one function to another, one
might say
.DS
\fBint f();
\&...
g(f);\fR
.DE
.PP
.ne 8
Then the definition of
.B
g
.R
might read
.DS
\fBg(funcp)
        int (\(**funcp)();
{
        ...
        (\(**funcp)();
        ...
}\fR
.DE
.PP
Notice that
.B
f
.R
must be declared
explicitly in the calling routine since its appearance
in
.B
g(f)
.R
was not followed by
.B
(.
.R
.nr Hu 1
.NH 2
Arrays, Pointers, and Subscripting
.PP
Every time an identifier of array type appears
in an expression, it is converted into a pointer
to the first member of the array.
Because of this conversion, arrays are not
lvalues.
By definition, the subscript operator
.B
[]
.R
is interpreted
in such a way that
.B
E1[E2]
.R
is identical to
.B
\(**((E1)\(plE2))\fR.
.R
Because of the conversion rules
which apply to
\fB\(pl\fR,
if
.B
E1
.R
is an array and
.B
E2
.R
an integer,
then
.B
E1[E2]
.R
refers to the
.B
E2-th
.R
member of
.B
E1\fR.
.R
Therefore,
despite its asymmetric
appearance, subscripting is a commutative operation.
.PP
A consistent rule is followed in the case of
multidimensional arrays.
If
.B
E
.R
is an
\fIn\fR-dimensional
array
of rank
i\(muj\(mu...\(muk,
then
.B
E
.R
appearing in an expression is converted to
a pointer to an (n-1)-dimensional
array with rank
j\(mu...\(muk.
If the
.B
\(**
.R
operator, either explicitly
or implicitly as a result of subscripting,
is applied to this pointer,
the result is the pointed-to (n-1)-dimensional array,
which itself is immediately converted into a pointer.
.PP
For example, consider
.DS
\fBint x[3][5];\fR
.DE
.PP
Here
.B
x
.R
is a 3\(mu5 array of integers.
When
.B
x
.R
appears in an expression, it is converted
to a pointer to (the first of three) 5-membered arrays of integers.
In the expression
\fBx[i]\fR,
which is equivalent to
\fB\(**(x\(pli)\fR,
.B
x
.R
is first converted to a pointer as described;
then
.B
i
.R
is converted to the type of
\fBx\fR,
which involves multiplying
.B
i
.R
by the
length the object to which the pointer points,
namely 5-integer objects.
The results are added and indirection applied to
yield an array (of five integers) which in turn is converted to
a pointer to the first of the integers.
If there is another subscript, the same argument applies
again; this time the result is an integer.
.PP
Arrays in C are stored
row-wise (last subscript varies fastest)
and the first subscript in the declaration helps determine
the amount of storage consumed by an array.
Arrays play no other part in subscript calculations.
.nr Hu 1
.NH 2
Explicit Pointer Conversions
.PP
Certain conversions involving pointers are permitted
but have implementation-dependent aspects.
They are all specified by means of an explicit type-conversion
operator, see ``Unary Operators'' under``EXPRESSIONS'' and
``Type Names''under ``DECLARATIONS.''
.PP
A pointer may be converted to any of the integral types large
enough to hold it.
Whether an
.B
int
.R
or
.B
long
.R
is required is machine dependent.
The mapping function is also machine dependent but is intended
to be unsurprising to those who know the addressing structure
of the machine.
Details for some particular machines are given below.
.PP
An object of integral type may be explicitly converted to a pointer.
The mapping always carries an integer converted from a pointer back to the same pointer
but is otherwise machine dependent.
.PP
A pointer to one type may be converted to a pointer to another type.
The resulting pointer may cause addressing exceptions
upon use if
the subject pointer does not refer to an object suitably aligned in storage.
It is guaranteed that
a pointer to an object of a given size may be converted to a pointer to an object
of a smaller size
and back again without change.
.PP
For example,
a storage-allocation routine
might accept a size (in bytes)
of an object to allocate, and return a
.B
char
.R
pointer;
it might be used in this way.
.DS
\fBextern char \(**malloc();
double \(**dp;
.sp
dp = (double \(**) malloc(sizeof(double));
\(**dp = 22.0 / 7.0;\fR
.DE
.PP
The
.B
alloc
.R
must ensure (in a machine-dependent way)
that its return value is suitable for conversion to a pointer to
\fBdouble\fR;
then the
.I
use
.R
of the function is portable.
.PP
The pointer
representation on the
PDP-11
corresponds to a 16-bit integer and
measures bytes.
The
.B
char\fR's
have no alignment requirements; everything else must have an even address.
.PP
On the
VAX-11,
pointers are 32 bits long and measure bytes.
Elementary objects are aligned on a boundary equal to their
length, except that
.B
double
.R
quantities need be aligned only on even 4-byte boundaries.
Aggregates are aligned on the strictest boundary required by
any of their constituents.
.PP
The 3B 20 computer has 24-bit pointers placed into 32-bit quantities.
Most objects are
aligned on 4-byte boundaries. \fBShort\fRs are aligned in all cases on
2-byte boundaries. Arrays of characters, all structures,
\fBint\fR\^s, \fBlong\fR\^s, \fBfloat\fR\^s, and \fBdouble\fR\^s are aligned on 4-byte
boundaries; but structure members may be packed tighter.
.nr Hu 1
.NH 2
CONSTANT EXPRESSIONS
.PP
In several places C requires expressions that evaluate to
a constant:
after
\fBcase\fR,
as array bounds, and in initializers.
In the first two cases, the expression can
involve only integer constants, character constants,
casts to integral types,
enumeration constants,
and
.B
sizeof
.R
expressions, possibly
connected by the binary operators
.ne 10
.DS
\(pl \(mi \(** / % & | ^ << >> == != < > <= >= && ||
.DE
.LP
or by the unary operators
.DS
\(mi  \s+2~\s0
.DE
.LP
or by the ternary operator
.DS
?:
.DE
.PP
Parentheses can be used for grouping
but not for function calls.
.PP
More latitude is permitted for initializers;
besides constant expressions as discussed above,
one can also use floating constants
and arbitrary casts and
can also apply the unary
.B
&
.R
operator to external or static objects
and to external or static arrays subscripted
with a constant expression.
The unary
.B
&
.R
can also
be applied implicitly
by appearance of unsubscripted arrays and functions.
The basic rule is that initializers must
evaluate either to a constant or to the address
of a previously declared external or static object plus or minus a constant.
.nr Hu 1
.NH 1
Portability Considerations
.PP
Certain parts of C are inherently machine dependent.
The following list of potential trouble spots
is not meant to be all-inclusive
but to point out the main ones.
.PP
Purely hardware issues like
word size and the properties of floating point arithmetic and integer division
have proven in practice to be not much of a problem.
Other facets of the hardware are reflected
in differing implementations.
Some of these,
particularly sign extension
(converting a negative character into a negative integer)
and the order in which bytes are placed in a word,
are nuisances that must be carefully watched.
Most of the others are only minor problems.
.PP
The number of
.B
register
.R
variables that can actually be placed in registers
varies from machine to machine
as does the set of valid types.
Nonetheless, the compilers all do things properly for their own machine;
excess or invalid
.B
register
.R
declarations are ignored.
.PP
Some difficulties arise only when
dubious coding practices are used.
It is exceedingly unwise to write programs
that depend
on any of these properties.
.PP
The order of evaluation of function arguments
is not specified by the language.
The order in which side effects take place
is also unspecified.
.PP
Since character constants are really objects of type
\fBint\fR,
multicharacter character constants may be permitted.
The specific implementation
is very machine dependent
because the order in which characters
are assigned to a word
varies from one machine to another.
.PP
Fields are assigned to words and characters to integers right to left
on some machines
and left to right on other machines.
These differences are invisible to isolated programs
that do not indulge in type punning (e.g.,
by converting an
.B
int
.R
pointer to a
.B
char
.R
pointer and inspecting the pointed-to storage)
but must be accounted for when conforming to externally-imposed
storage layouts.
.nr Hu 1
.NH 1
Syntax Summary
.PP
This summary of C syntax is intended more for aiding comprehension
than as an exact statement of the language.
.nr Hu 1
.ne 18
.NH 2
Expressions
.PP
The basic expressions are:
.tr ~~
.DS
     \fIexpression:
             primary
             \(** expression\fR
             &\fIlvalue
             \(mi expression
             ! expression
             \s+2~\s0 expression
             \(pl\(pl lvalue
             \(mi\(milvalue
             lvalue \(pl\(pl
             lvalue \(mi\(mi
             \fBsizeof\fI expression
             \fBsizeof (\fItype-name\fB)\fI
             ( type-name ) expression
             expression binop expression
             expression ? expression : expression
             lvalue asgnop expression
             expression , expression
.DE
.DS
     \fIprimary:
             identifier
             constant
             string
             ( expression )
             primary ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
             primary [ expression ]
             primary . identifier
             primary \(mi identifier
.DE
.DS
     \fIlvalue:
             identifier
             primary [ expression ]
             lvalue . identifier
             primary \(mi identifier
             \(** expression
             ( lvalue )\fR
.DE
.PP
.PP
The primary-expression operators
.DS
     ()  []  .  \(mi
.tr ~~
.DE
.LP
have highest priority and group left to right.
The unary operators
.DS
     \(**  &  \(mi  !  \s+2~\s0  \(pl\(pl \(mi\(mi \fBsizeof\fI   ( type-name \fR)
.DE
.LP
have priority below the primary operators
but higher than any binary operator
and group right to left.
Binary operators
group left to right; they have priority
decreasing
as indicated below.
.DS
     \fIbinop:\fR
             \(**    /    %
             \(pl    \(mi
             >>   <<
             <    >    <=    >=
             ==   !=
             &
             ^
             |
             &&
             ||
.DE
The conditional operator groups right to left.
.PP
Assignment operators all have the same
priority and all group right to left.
.DS
     \fIasgnop:\fR
             =  \(pl=  \(mi=  \(**=  /=  %=  >>=  <<=  &=  ^=  |=
.DE
.PP
The comma operator has the lowest priority and groups left to right.
.nr Hu 1
.NH 2
Declarations
.PP
.DS
     \fIdeclaration:
             decl-specifiers init-declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;
.DE
.DS
     \fIdecl-specifiers:
             type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
             sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
.DE
.DS
     \fIsc-specifier:\fB
             auto
             static
             extern
             register
             typedef
.DE
.DS
     \fItype-specifier:
             struct-or-union-specifier
             typedef-name
             enum-specifier
     basic-type-specifier:
             basic-type
             basic-type basic-type-specifiers
     basic-type:\fB
             char
             short
             int
             long
             unsigned
             float
             double
             void\fR
.DE
.DS
\fIenum-specifier:\fB
             enum\fI { enum-list }\fB
             enum \fIidentifier { enum-list }\fB
             enum \fIidentifier
.DE
.DS
     \fIenum-list:
             enumerator
             enum-list , enumerator
.DE
.DS
     \fIenumerator:
             identifier
             identifier = constant-expression
.DE
.DS
     \fIinit-declarator-list:
             init-declarator
             init-declarator , init-declarator-list
.DE
.DS
     \fIinit-declarator:
             declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'
.DE
.DS
     \fIdeclarator:
             identifier
             ( declarator )
             \(** declarator
             declarator ()
             declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
.DE
.DS
     \fIstruct-or-union-specifier:\fB
             struct\fI { struct-decl-list }\fB
             struct \fIidentifier { struct-decl-list }\fB
             struct \fIidentifier\fB
             union { \fIstruct-decl-list }\fB
             union \fIidentifier { struct-decl-list }\fB
             union \fIidentifier
.DE
.DS
     \fIstruct-decl-list:
             struct-declaration
             struct-declaration struct-decl-list
.DE
.DS
     \fIstruct-declaration:
             type-specifier struct-declarator-list ;
.DE
.DS
     \fIstruct-declarator-list:
             struct-declarator
             struct-declarator , struct-declarator-list
.DE
.DS
     \fIstruct-declarator:
             declarator
             declarator : constant-expression
             : constant-expression
.DE
.DS
     \fIinitializer:
             = expression
             = { initializer-list }
             = { initializer-list , }
.DE
.DS
     \fIinitializer-list:
             expression
             initializer-list , initializer-list
             { initializer-list }
             { initializer-list , }
.DE
.DS
     \fItype-name:
             type-specifier abstract-declarator
.DE
.DS
     \fIabstract-declarator:
             empty
             ( abstract-declarator )
             \(** abstract-declarator
             abstract-declarator ()
             abstract-declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
.DE
.DS
     \fItypedef-name:
             identifier
.nr Hu 1
.DE
.NH 2
Statements
.PP
.DS
     \fIcompound-statement:
             { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
.DE
.DS
     \fIdeclaration-list:
             declaration
             declaration declaration-list
.DE
.DS
     \fIstatement-list:
             statement
             statement statement-list
.DE
.DS
     \fIstatement:
             compound-statement
             expression ;
             \fBif\fI ( expression ) statement
             \fBif\fI ( expression ) statement  \fBelse\fI statement
             \fBwhile\fI ( expression ) statement
             \fBdo\fI statement  \fBwhile\fI ( expression ) ;
             \fBfor\fI (exp\v'0.3'\s-2opt\s0\v'-0.3'\fB;\fIexp\v'0.3'\s-2opt\s0\v'-0.3'\fB;\fIexp\v'0.3'\s-2opt\s0\v'-0.3'\fI) statement
             \fBswitch\fI ( expression ) statement
             \fBcase\fI constant-expression :  statement
             \fBdefault\fI : statement
             \fBbreak ;
             continue ;
             return ;
             return\fI expression ;
             \fBgoto\fI identifier ;
             identifier : statement
             ;\fR
.nr Hu 1
.DE
.NH 2
External definitions
.PP
.DS
     \fIprogram:
             external-definition
             external-definition program
.DE
.DS
     \fIexternal-definition:
             function-definition
             data-definition
.DE
.DS
     \fIfunction-definition:
             decl-specifier\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body
.DE
.DS
     \fIfunction-declarator:
             declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
.DE
.DS
     \fIparameter-list:
             identifier
             identifier , parameter-list
.DE
.DS
     \fIfunction-body:
             declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement
.DE
.DS
     \fIdata-definition:
             \fBextern\fI declaration\fB ;
             \fBstatic\fI declaration\fB ;
.DE
.NH
Preprocessor
.DS
             \fB#define\fI identifier token-string\v'0.3'\s-2opt\s0\v'-0.3'\fB
             \fB#define\fI identifier\fB(\fIidentifier\fB,...)\fItoken-string\v'0.5'\s-2opt\s0\v'-0.5'\fB
             \fB#undef\fI identifier\fB
             \fB#include "\fIfilename\|\fB"
             #include <\fIfilename\|\fB>
             \fB#if\fI restricted-constant-expression\fB
             \fB#ifdef\fI identifier\fB
             \fB#ifndef\fI identifier\fB
             \fB#else
             \fB#endif
             \fB#line\fI constant \fB"\fIfilename\|\fB"
.sp 5
.DE
.\" .TC 2 1 3 0