home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / msdos / djgpp / docs / gcc / gcc.i5 < prev    next >
Encoding:
GNU Info File  |  1993-05-29  |  49.6 KB  |  1,227 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and "Protect
  15. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  24. permission notice, may be included in translations approved by the Free
  25. Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gcc.info,  Node: Cross-Compiler,  Next: PA Install,  Prev: Other Dir,  Up: Installation
  29.  
  30. Building and Installing a Cross-Compiler
  31. ========================================
  32.  
  33.    GNU CC can function as a cross-compiler for many machines, but not
  34. all.
  35.  
  36.    * Cross-compilers for the Mips as target do not work because the
  37.      auxiliary programs `mips-tdump.c' and `mips-tfile.c' can't be
  38.      compiled on anything but a Mips.
  39.  
  40.    * Cross-compilers to or from the Vax probably don't work completely
  41.      because the Vax uses an incompatible floating point format (not
  42.      IEEE format).
  43.  
  44.    Since GNU CC generates assembler code, you probably need a
  45. cross-assembler that GNU CC can run, in order to produce object files.
  46. If you want to link on other than the target machine, you need a
  47. cross-linker as well.  You also need header files and libraries suitable
  48. for the target machine that you can install on the host machine.
  49.  
  50.    To build GNU CC as a cross-compiler, you start out by running
  51. `configure'.  You must specify two different configurations, the host
  52. and the target.  Use the `--host=HOST' option for the host and
  53. `--target=TARGET' to specify the target type.  For example, here is how
  54. to configure for a cross-compiler that runs on a hypothetical Intel 386
  55. system and produces code for an HP 68030 system running BSD:
  56.  
  57.      configure --target=m68k-hp-bsd4.3 --host=i386-bozotheclone-bsd4.3
  58.  
  59.    Next you should install the cross-assembler and cross-linker (and
  60. `ar' and `ranlib').  Put them in the directory `/usr/local/TARGET/bin'.
  61. The installation of GNU CC will find them there and copy or link them
  62. to the proper place to find them when you run the cross-compiler later.
  63.  
  64.    If you want to install any additional libraries to use with the
  65. cross-compiler, put them in the directory `/usr/local/TARGET/lib'; all
  66. files in that subdirectory will be installed in the proper place when
  67. you install the cross-compiler.  Likewise, put the header files for the
  68. target machine in `/usr/local/TARGET/include'.
  69.  
  70.    You must now produce a substitute for `libgcc1.a'.  Normally this
  71. file is compiled with the "native compiler" for the target machine;
  72. compiling it with GNU CC does not work.  But compiling it with the host
  73. machine's compiler also doesn't work--that produces a file that would
  74. run on the host, and you need it to run on the target.
  75.  
  76.    We can't give you any automatic way to produce this substitute.  For
  77. some targets, the subroutines in `libgcc1.c' are not actually used.
  78. You need not provide the ones that won't be used.  The ones that most
  79. commonly are used are the multiplication, division and remainder
  80. routines--many RISC machines rely on the library for this.  One way to
  81. make them work is to define the appropriate `perform_...' macros for
  82. the subroutines that you need.  If these definitions do not use the C
  83. arithmetic operators that they are meant to implement, you might be
  84. able to compile them with the cross-compiler you are building.  To do
  85. this, specify `LIBGCC1=libgcc1.a OLDCC=./xgcc' when building the
  86. compiler.
  87.  
  88.    Now you can proceed just as for compiling a single-machine compiler
  89. through the step of building stage 1.  If you have not provided some
  90. sort of `libgcc1.a', then compilation will give up at the point where
  91. it needs that file, printing a suitable error message.  If you do
  92. provide `libgcc1.a', then building the compiler will automatically
  93. compile and link a test program called `cross-test'; if you get errors
  94. in the linking, it means that not all of the necessary routines in
  95. `libgcc1.a' are available.
  96.  
  97.    When you are using a cross-compiler configuration, building stage 1
  98. does not compile all of GNU CC.  This is because one part of building,
  99. the compilation of `libgcc2.c', requires use of the cross-compiler.
  100.  
  101.    However, when you type `make install' to install the bulk of the
  102. cross-compiler, that will also compile `libgcc2.c' and install the
  103. resulting `libgcc.a'.
  104.  
  105.    Do not try to build stage 2 for a cross-compiler.  It doesn't work to
  106. rebuild GNU CC as a cross-compiler using the cross-compiler, because
  107. that would produce a program that runs on the target machine, not on the
  108. host.  For example, if you compile a 386-to-68030 cross-compiler with
  109. itself, the result will not be right either for the 386 (because it was
  110. compiled into 68030 code) or for the 68030 (because it was configured
  111. for a 386 as the host).  If you want to compile GNU CC into 68030 code,
  112. whether you compile it on a 68030 or with a cross-compiler on a 386, you
  113. must specify a 68030 as the host when you configure it.
  114.  
  115. 
  116. File: gcc.info,  Node: PA Install,  Next: Sun Install,  Prev: Cross-Compiler,  Up: Installation
  117.  
  118. GNU CC on the HP Precision Architecture
  119. =======================================
  120.  
  121.    There are two variants of this CPU, called 1.0 and 1.1, which have
  122. different machine descriptions.  You must use the right one for your
  123. machine.  All 7NN machines and 8N7 machines use 1.1, while all other
  124. 8NN machines use 1.0.
  125.  
  126.    The easiest way to handle this problem is to use `configure hpNNN'
  127. or `configure hpNNN-hpux', where NNN is the model number of the
  128. machine.  Then `configure' will figure out if the machine is a 1.0 or
  129. 1.1.  Use `uname -a' to find out the model number of your machine.
  130.  
  131.    `-g' does not work on HP-UX, since that system uses a peculiar
  132. debugging format which GNU CC does not know about.  There are
  133. preliminary versions of GAS and GDB for the HP-PA which do work with
  134. GNU CC for debugging.  You can get them by anonymous ftp from
  135. `jaguar.cs.utah.edu' `dist' subdirectory.  You would need to install
  136. GAS in the file
  137.  
  138.      /usr/local/lib/gcc-lib/CONFIGURATION/GCCVERSION/as
  139.  
  140. where CONFIGURATION is the configuration name (perhaps `hpNNN-hpux')
  141. and GCCVERSION is the GNU CC version number.  Do this *before* starting
  142. the build process, otherwise you will get errors from the HPUX
  143. assembler while building `libgcc2.a'.  The command
  144.  
  145.      make install-dir
  146.  
  147. will create the necessary directory hierarchy so you can install GAS
  148. before building GCC.
  149.  
  150.    If you obtained GAS before October 6, 1992 it is highly recommended
  151. you get a new one to avoid several bugs which have been discovered
  152. recently.
  153.  
  154.    To enable debugging, configure GNU CC with the `--gas' option before
  155. building.
  156.  
  157.    It has been reported that GNU CC produces invalid assembly code for
  158. 1.1 machines running HP-UX 8.02 when using the HP assembler.  Typically
  159. the errors look like this:
  160.      as: bug.s @line#15 [err#1060]
  161.        Argument 0 or 2 in FARG upper
  162.               - lookahead = ARGW1=FR,RTNVAL=GR
  163.      as: foo.s @line#28 [err#1060]
  164.        Argument 0 or 2 in FARG upper
  165.               - lookahead = ARGW1=FR
  166.  
  167.    You can check the version of HP-UX you are running by executing the
  168. command `uname -r'.   If you are indeed running HP-UX 8.02 on a 1.1
  169. machine and using the HP assembler then configure GCC with
  170. "hp700-hpux8.02".
  171.  
  172. 
  173. File: gcc.info,  Node: Sun Install,  Next: 3b1 Install,  Prev: PA Install,  Up: Installation
  174.  
  175. Installing GNU CC on the Sun
  176. ============================
  177.  
  178.    Make sure the environment variable `FLOAT_OPTION' is not set when
  179. you compile `libgcc.a'.  If this option were set to `f68881' when
  180. `libgcc.a' is compiled, the resulting code would demand to be linked
  181. with a special startup file and would not link properly without special
  182. pains.
  183.  
  184.    There is a bug in `alloca' in certain versions of the Sun library.
  185. To avoid this bug, install the binaries of GNU CC that were compiled by
  186. GNU CC.  They use `alloca' as a built-in function and never the one in
  187. the library.
  188.  
  189.    Some versions of the Sun compiler crash when compiling GNU CC.  The
  190. problem is a segmentation fault in cpp.  This problem seems to be due to
  191. the bulk of data in the environment variables.  You may be able to avoid
  192. it by using the following command to compile GNU CC with Sun CC:
  193.  
  194.      make CC="TERMCAP=x OBJS=x LIBFUNCS=x STAGESTUFF=x cc"
  195.  
  196. 
  197. File: gcc.info,  Node: 3b1 Install,  Next: Unos Install,  Prev: Sun Install,  Up: Installation
  198.  
  199. Installing GNU CC on the 3b1
  200. ============================
  201.  
  202.    Installing GNU CC on the 3b1 is difficult if you do not already have
  203. GNU CC running, due to bugs in the installed C compiler.  However, the
  204. following procedure might work.  We are unable to test it.
  205.  
  206.   1. Comment out the `#include "config.h"' line on line 37 of `cccp.c'
  207.      and do `make cpp'.  This makes a preliminary version of GNU cpp.
  208.  
  209.   2. Save the old `/lib/cpp' and copy the preliminary GNU cpp to that
  210.      file name.
  211.  
  212.   3. Undo your change in `cccp.c', or reinstall the original version,
  213.      and do `make cpp' again.
  214.  
  215.   4. Copy this final version of GNU cpp into `/lib/cpp'.
  216.  
  217.   5. Replace every occurrence of `obstack_free' in the file `tree.c'
  218.      with `_obstack_free'.
  219.  
  220.   6. Run `make' to get the first-stage GNU CC.
  221.  
  222.   7. Reinstall the original version of `/lib/cpp'.
  223.  
  224.   8. Now you can compile GNU CC with itself and install it in the normal
  225.      fashion.
  226.  
  227. 
  228. File: gcc.info,  Node: Unos Install,  Next: VMS Install,  Prev: 3b1 Install,  Up: Installation
  229.  
  230. Installing GNU CC on Unos
  231. =========================
  232.  
  233.    Use `configure unos' for building on Unos.
  234.  
  235.    The Unos assembler is named `casm' instead of `as'.  For some
  236. strange reason linking `/bin/as' to `/bin/casm' changes the behavior,
  237. and does not work.  So, when installing GNU CC, you should install the
  238. following script as `as' in the subdirectory where the passes of GCC
  239. are installed:
  240.  
  241.      #!/bin/sh
  242.      casm $*
  243.  
  244.    The default Unos library is named `libunos.a' instead of `libc.a'.
  245. To allow GNU CC to function, either change all references to `-lc' in
  246. `gcc.c' to `-lunos' or link `/lib/libc.a' to `/lib/libunos.a'.
  247.  
  248.    When compiling GNU CC with the standard compiler, to overcome bugs in
  249. the support of `alloca', do not use `-O' when making stage 2.  Then use
  250. the stage 2 compiler with `-O' to make the stage 3 compiler.  This
  251. compiler will have the same characteristics as the usual stage 2
  252. compiler on other systems.  Use it to make a stage 4 compiler and
  253. compare that with stage 3 to verify proper compilation.
  254.  
  255.    (Perhaps simply defining `ALLOCA' in `x-crds' as described in the
  256. comments there will make the above paragraph superfluous.  Please
  257. inform us of whether this works.)
  258.  
  259.    Unos uses memory segmentation instead of demand paging, so you will
  260. need a lot of memory.  5 Mb is barely enough if no other tasks are
  261. running.  If linking `cc1' fails, try putting the object files into a
  262. library and linking from that library.
  263.  
  264. 
  265. File: gcc.info,  Node: VMS Install,  Next: WE32K Install,  Prev: Unos Install,  Up: Installation
  266.  
  267. Installing GNU CC on VMS
  268. ========================
  269.  
  270.    The VMS version of GNU CC is distributed in a backup saveset
  271. containing both source code and precompiled binaries.
  272.  
  273.    To install the `gcc' command so you can use the compiler easily, in
  274. the same manner as you use the VMS C compiler, you must install the VMS
  275. CLD file for GNU CC as follows:
  276.  
  277.   1. Define the VMS logical names `GNU_CC' and `GNU_CC_INCLUDE' to
  278.      point to the directories where the GNU CC executables
  279.      (`gcc-cpp.exe', `gcc-cc1.exe', etc.) and the C include files are
  280.      kept respectively.  This should be done with the commands:
  281.  
  282.           $ assign /system /translation=concealed -
  283.             disk:[gcc.] gnu_cc
  284.           $ assign /system /translation=concealed -
  285.             disk:[gcc.include.] gnu_cc_include
  286.  
  287.      with the appropriate disk and directory names.  These commands can
  288.      be placed in your system startup file so they will be executed
  289.      whenever the machine is rebooted.  You may, if you choose, do this
  290.      via the `GCC_INSTALL.COM' script in the `[GCC]' directory.
  291.  
  292.   2. Install the `GCC' command with the command line:
  293.  
  294.           $ set command /table=sys$common:[syslib]dcltables -
  295.             /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
  296.           $ install replace sys$common:[syslib]dcltables
  297.  
  298.   3. To install the help file, do the following:
  299.  
  300.           $ library/help sys$library:helplib.hlb gcc.hlp
  301.  
  302.      Now you can invoke the compiler with a command like `gcc /verbose
  303.      file.c', which is equivalent to the command `gcc -v -c file.c' in
  304.      Unix.
  305.  
  306.    If you wish to use GNU C++ you must first install GNU CC, and then
  307. perform the following steps:
  308.  
  309.   1. Define the VMS logical name `GNU_GXX_INCLUDE' to point to the
  310.      directory where the preprocessor will search for the C++ header
  311.      files.  This can be done with the command:
  312.  
  313.           $ assign /system /translation=concealed -
  314.             disk:[gcc.gxx_include.] gnu_gxx_include
  315.  
  316.      with the appropriate disk and directory name.  If you are going to
  317.      be using libg++, this is where the libg++ install procedure will
  318.      install the libg++ header files.
  319.  
  320.   2. Obtain the file `gcc-cc1plus.exe', and place this in the same
  321.      directory that `gcc-cc1.exe' is kept.
  322.  
  323.      The GNU C++ compiler can be invoked with a command like `gcc /plus
  324.      /verbose file.cc', which is equivalent to the command `g++ -v -c
  325.      file.cc' in Unix.
  326.  
  327.    We try to put corresponding binaries and sources on the VMS
  328. distribution tape.  But sometimes the binaries will be from an older
  329. version than the sources, because we don't always have time to update
  330. them.  (Use the `/version' option to determine the version number of
  331. the binaries and compare it with the source file `version.c' to tell
  332. whether this is so.)  In this case, you should use the binaries you get
  333. to recompile the sources.  If you must recompile, here is how:
  334.  
  335.   1. Execute the command procedure `vmsconfig.com' to copy files
  336.      `vax-vms.h', `xm-vax-vms.h', `vax.c' and `vax.md' to files `tm.h',
  337.      `config.h', `aux-output.c', and `md.' respectively, and to create
  338.      files `tconfig.h' and `hconfig.h'.  This procedure also creates
  339.      several linker option files used by `make-cc1.com' and a data file
  340.      used by `make-l2.com'.
  341.  
  342.           $ @vmsconfig.com
  343.  
  344.   2. Setup the logical names and command tables as defined above.  In
  345.      addition, define the VMS logical name `GNU_BISON' to point at the
  346.      to the directories where the Bison executable is kept.  This
  347.      should be done with the command:
  348.  
  349.           $ assign /system /translation=concealed -
  350.             disk:[bison.] gnu_bison
  351.  
  352.      You may, if you choose, use the `INSTALL_BISON.COM' script in the
  353.      `[BISON]' directory.
  354.  
  355.   3. Install the `BISON' command with the command line:
  356.  
  357.           $ set command /table=sys$common:[syslib]dcltables -
  358.             /output=sys$common:[syslib]dcltables -
  359.             gnu_bison:[000000]bison
  360.           $ install replace sys$common:[syslib]dcltables
  361.  
  362.   4. Type `@make-gcc' to recompile everything (alternatively, you may
  363.      submit the file `make-gcc.com' to a batch queue).  If you wish to
  364.      build the GNU C++ compiler as well as the GNU CC compiler, you must
  365.      first edit `make-gcc.com' and follow the instructions that appear
  366.      in the comments.
  367.  
  368.   5. In order to use GCC, you need a library of functions which GCC
  369.      compiled code will call to perform certain tasks, and these
  370.      functions are defined in the file `libgcc2.c'.  To compile this
  371.      you should use the command procedure `make-l2.com', which will
  372.      generate the library `libgcc2.olb'.  `libgcc2.olb' should be built
  373.      using the compiler built from the same distribution that
  374.      `libgcc2.c' came from, and `make-gcc.com' will automatically do
  375.      all of this for you.
  376.  
  377.      To install the library, use the following commands:
  378.  
  379.           $ library gnu_cc:[000000]gcclib/delete=(new,eprintf)
  380.           $ library gnu_cc:[000000]gcclib/delete=L_*
  381.           $ library libgcc2/extract=*/output=libgcc2.obj
  382.           $ library gnu_cc:[000000]gcclib libgcc2.obj
  383.  
  384.      The first command simply removes old modules that will be replaced
  385.      with modules from `libgcc2' under different module names.  The
  386.      modules `new' and `eprintf' may not actually be present in your
  387.      `gcclib.olb'--if the VMS librarian complains about those modules
  388.      not being present, simply ignore the message and continue on with
  389.      the next command.  The second command removes the modules that
  390.      came from the previous version of the library `libgcc2.c'.
  391.  
  392.      Whenever you update the compiler on your system, you should also
  393.      update the library with the above procedure.
  394.  
  395.   6. You may wish to build GCC in such a way that no files are written
  396.      to the directory where the source files reside.  An example would
  397.      be the when the source files are on a read-only disk.  In these
  398.      cases, execute the following DCL commands (substituting your
  399.      actual path names):
  400.  
  401.           $ assign dua0:[gcc.build_dir.]/translation=concealed, -
  402.                    dua1:[gcc.source_dir.]/translation=concealed  gcc_build
  403.           $ set default gcc_build:[000000]
  404.  
  405.      where `dua1:[gcc.source_dir]' contains the source code, and
  406.      `dua0:[gcc.build_dir]' is meant to contain all of the generated
  407.      object files and executables.  Once you have done this, you can
  408.      proceed building GCC as described above.  (Keep in mind that
  409.      `gcc_build' is a rooted logical name, and thus the device names in
  410.      each element of the search list must be an actual physical device
  411.      name rather than another rooted logical name).
  412.  
  413.   7. *If you are building GNU CC with a previous version of GNU CC, you
  414.      also should check to see that you have the newest version of the
  415.      assembler*.  In particular, GNU CC version 2 treats global constant
  416.      variables slightly differently from GNU CC version 1, and GAS
  417.      version 1.38.1 does not have the patches required to work with GCC
  418.      version 2.  If you use GAS 1.38.1, then `extern const' variables
  419.      will not have the read-only bit set, and the linker will generate
  420.      warning messages about mismatched psect attributes for these
  421.      variables.  These warning messages are merely a nuisance, and can
  422.      safely be ignored.
  423.  
  424.      If you are compiling with a version of GNU CC older than 1.33,
  425.      specify `/DEFINE=("inline=")' as an option in all the
  426.      compilations.  This requires editing all the `gcc' commands in
  427.      `make-cc1.com'.  (The older versions had problems supporting
  428.      `inline'.)  Once you have a working 1.33 or newer GNU CC, you can
  429.      change this file back.
  430.  
  431.   8. If you want to build GNU CC with the VAX C compiler, you will need
  432.      to make minor changes in `make-cccp.com' and `make-cc1.com' to
  433.      choose alternate definitions of `CC', `CFLAGS', and `LIBS'.  See
  434.      comments in those files.  However, you must also have a working
  435.      version of the GNU assembler (GNU as, aka GAS) as it is used as
  436.      the back-end for GNU CC to produce binary object modules and is
  437.      not included in the GNU CC sources.  GAS is also needed to compile
  438.      `libgcc2' in order to build `gcclib' (see above); `make-l2.com'
  439.      expects to be able to find it operational in
  440.      `gnu_cc:[000000]gnu-as.exe'.
  441.  
  442.      To use GNU CC on VMS, you need the VMS driver programs `gcc.exe',
  443.      `gcc.com', and `gcc.cld'.  They are distributed with the VMS
  444.      binaries (`gcc-vms') rather than the GNU CC sources.  GAS is also
  445.      included in `gcc-vms', as is Bison.
  446.  
  447.      Once you have successfully built GNU CC with VAX C, you should use
  448.      the resulting compiler to rebuild itself.  Before doing this, be
  449.      sure to restore the `CC', `CFLAGS', and `LIBS' definitions in
  450.      `make-cccp.com' and `make-cc1.com'.  The second generation
  451.      compiler will be able to take advantage of many optimizations that
  452.      must be suppressed when building with other compilers.
  453.  
  454.    Under previous versions of GNU CC, the generated code would
  455. occasionally give strange results when linked with the sharable
  456. `VAXCRTL' library.  Now this should work.
  457.  
  458.    Even with this version, however, GNU CC itself should not be linked
  459. with the sharable `VAXCRTL'.  The version of `qsort' in `VAXCRTL' has a
  460. bug (known to be present in VMS versions V4.6 through V5.5) which
  461. causes the compiler to fail.
  462.  
  463.    The executables are generated by `make-cc1.com' and `make-cccp.com'
  464. use the object library version of `VAXCRTL' in order to make use of the
  465. `qsort' routine in `gcclib.olb'.  If you wish to link the compiler
  466. executables with the shareable image version of `VAXCRTL', you should
  467. edit the file `tm.h' (created by `vmsconfig.com') to define the macro
  468. `QSORT_WORKAROUND'.
  469.  
  470.    `QSORT_WORKAROUND' is always defined when GNU CC is compiled with
  471. VAX C, to avoid a problem in case `gcclib.olb' is not yet available.
  472.  
  473. 
  474. File: gcc.info,  Node: WE32K Install,  Next: MIPS Install,  Prev: VMS Install,  Up: Installation
  475.  
  476. Installing GNU CC on the WE32K
  477. ==============================
  478.  
  479.    These computers are also known as the 3b2, 3b5, 3b20 and other
  480. similar names.  (However, the 3b1 is actually a 68000; see *Note 3b1
  481. Install::.)
  482.  
  483.    Don't use `-g' when compiling with the system's compiler.  The
  484. system's linker seems to be unable to handle such a large program with
  485. debugging information.
  486.  
  487.    The system's compiler runs out of capacity when compiling `stmt.c'
  488. in GNU CC.  You can work around this by building `cpp' in GNU CC first,
  489. then use that instead of the system's preprocessor with the system's C
  490. compiler to compile `stmt.c'.  Here is how:
  491.  
  492.      mv /lib/cpp /lib/cpp.att
  493.      cp cpp /lib/cpp.gnu
  494.      echo "/lib/cpp.gnu -traditional $*" > /lib/cpp
  495.      chmod +x /lib/cpp
  496.  
  497.    The system's compiler produces bad code for some of the GNU CC
  498. optimization files.  So you must build the stage 2 compiler without
  499. optimization.  Then build a stage 3 compiler with optimization.  That
  500. executable should work.  Here are the necessary commands:
  501.  
  502.      make LANGUAGES=c CC=stage1/xgcc CFLAGS="-Bstage1/ -g"
  503.      make stage2
  504.      make CC=stage2/xgcc CFLAGS="-Bstage2/ -g -O"
  505.  
  506.    You may need to raise the ULIMIT setting to build a C++ compiler, as
  507. the file `cc1plus' is larger than one megabyte.
  508.  
  509. 
  510. File: gcc.info,  Node: MIPS Install,  Next: Collect2,  Prev: WE32K Install,  Up: Installation
  511.  
  512. Installing GNU CC on the MIPS
  513. =============================
  514.  
  515.    See *Note Installation:: about whether to use either of the options
  516. `--with-stabs' or `--with-gnu-as'.
  517.  
  518.    The MIPS C compiler needs to be told to increase its table size for
  519. switch statements with the `-Wf,-XNg1500' option in order to compile
  520. `cp-parse.c'.  If you use the `-O2' optimization option, you also need
  521. to use `-Olimit 3000'.  Both of these options are automatically
  522. generated in the `Makefile' that the shell script `configure' builds.
  523. If you override the `CC' make variable and use the MIPS compilers, you
  524. may need to add `-Wf,-XNg1500 -Olimit 3000'.
  525.  
  526.    MIPS computers running RISC-OS can support four different
  527. personalities: default, BSD 4.3, System V.3, and System V.4 (older
  528. versions of RISC-OS don't support V.4).  To configure GCC for these
  529. platforms use the following configurations:
  530.  
  531. `mips-mips-riscos`rev''
  532.      Default configuration for RISC-OS, revision `rev'.
  533.  
  534. `mips-mips-riscos`rev'bsd'
  535.      BSD 4.3 configuration for RISC-OS, revision `rev'.
  536.  
  537. `mips-mips-riscos`rev'sysv4'
  538.      System V.4 configuration for RISC-OS, revision `rev'.
  539.  
  540. `mips-mips-riscos`rev'sysv'
  541.      System V.3 configuration for RISC-OS, revision `rev'.
  542.  
  543.    The revision `rev' mentioned above is the revision of RISC-OS to
  544. use.  You must reconfigure GCC when going from a RISC-OS revision 4 to
  545. RISC-OS revision 5.  This has the effect of avoiding a linker bug (see
  546. *Note Installation Problems:: for more details).
  547.  
  548.    DECstations can support three different personalities: Ultrix, DEC
  549. OSF/1, and OSF/rose.  To configure GCC for these platforms use the
  550. following configurations:
  551.  
  552. `decstation-ultrix'
  553.      Ultrix configuration.
  554.  
  555. `decstation-osf1'
  556.      Dec's version of OSF/1.
  557.  
  558. `decstation-osfrose'
  559.      Open Software Foundation reference port of OSF/1 which uses the
  560.      OSF/rose object file format instead of ECOFF.  Normally, you would
  561.      not select this configuration.
  562.  
  563.    On Irix version 4.0.5F, and perhaps on some other versions as well,
  564. there is an assembler bug that reorders instructions incorrectly.  To
  565. work around it, specify the target configuration `mips-sgi-irix4loser'.
  566. This configuration inhibits assembler optimization.
  567.  
  568.    You can turn off assembler optimization in a compiler configured with
  569. target `mips-sgi-irix4' using the `-noasmopt' option.  This compiler
  570. option passes the option `-O0' to the assembler, to inhibit reordering.
  571.  
  572.    The `-noasmopt' option can be useful for testing whether a problem
  573. is due to erroneous assembler reordering.  Even if a problem does not go
  574. away with `-noasmopt', it may still be due to assembler
  575. reordering--perhaps GNU CC itself was miscompiled as a result.
  576.  
  577.    We know this is inconvenient, but it's the best that can be done at
  578. the last minute.
  579.  
  580. 
  581. File: gcc.info,  Node: Collect2,  Prev: MIPS Install,  Up: Installation
  582.  
  583. `collect2'
  584. ==========
  585.  
  586.    Many target systems do not have support in the assembler and linker
  587. for "constructors"--initialization functions to be called before the
  588. official "start" of `main'.  On such systems, GNU CC uses a utility
  589. called `collect2' to arrange to call these functions at start time.
  590.  
  591.    The program `collect2' works by linking the program once and looking
  592. through the linker output file for symbols with particular names
  593. indicating they are constructor functions.  If it finds any, it creates
  594. a new temporary `.c' file containing a table of them, compiles it, and
  595. links the program a second time including that file.
  596.  
  597.    The actual calls to the constructors are carried out by a subroutine
  598. called `__main', which is called (automatically) at the beginning of
  599. the body of `main' (provided `main' was compiled with GNU CC).
  600.  
  601.    The program `collect2' is installed as `ld' in the directory where
  602. the passes of the compiler are installed.  When `collect2' needs to
  603. find the *real* `ld', it tries the following file names:
  604.  
  605.    * `gld' in the directories listed in the compiler's search
  606.      directories.
  607.  
  608.    * `gld' in the directories listed in the environment variable `PATH'.
  609.  
  610.    * `real-ld' in the compiler's search directories.
  611.  
  612.    * `real-ld' in `PATH'.
  613.  
  614.    * `ld' in `PATH'.
  615.  
  616.    "The compiler's search directories" means all the directories where
  617. `gcc' searches for passes of the compiler.  This includes directories
  618. that you specify with `-B'.
  619.  
  620.    Cross compilers search a little differently:
  621.  
  622.    * `gld' in the compiler's search directories.
  623.  
  624.    * `TARGET-gld' in `PATH'.
  625.  
  626.    * `real-ld' in the compiler's search directories.
  627.  
  628.    * `TARGET-real-ld' in `PATH'.
  629.  
  630.    * `TARGET-ld' in `PATH'.
  631.  
  632.    `collect2' does not search for `ld' using the compiler's search
  633. directories, because if it did, it would find itself--not the real
  634. `ld'--and this could lead to infinite recursion.  However, the
  635. directory where `collect2' is installed might happen to be in `PATH'.
  636. That could lead `collect2' to invoke itself anyway.  when looking for
  637. `ld'.
  638.  
  639.    To prevent this, `collect2' explicitly avoids running `ld' using the
  640. file name under which `collect2' itself was invoked.  In fact, it
  641. remembers up to two such names--in case one copy of `collect2' finds
  642. another copy (or version) of `collect2' installed as `ld' in a second
  643. place in the search path.
  644.  
  645.    If two file names to avoid are not sufficient, you may still
  646. encounter an infinite recursion of `collect2' processes.  When this
  647. happens.  check all the files installed as `ld' in any of the
  648. directories searched, and straighten out the situation.
  649.  
  650.    (In a future version, we will probably change `collect2' to avoid
  651. any reinvocation of a file from which any parent `collect2' was run.)
  652.  
  653. 
  654. File: gcc.info,  Node: C Extensions,  Next: C++ Extensions,  Prev: Installation,  Up: Top
  655.  
  656. Extensions to the C Language Family
  657. ***********************************
  658.  
  659.    GNU C provides several language features not found in ANSI standard
  660. C.  (The `-pedantic' option directs GNU CC to print a warning message if
  661. any of these features is used.)  To test for the availability of these
  662. features in conditional compilation, check for a predefined macro
  663. `__GNUC__', which is always defined under GNU CC.
  664.  
  665.    These extensions are available in C and in the languages derived from
  666. it, C++ and Objective C.  *Note Extensions to the C++ Language: C++
  667. Extensions, for extensions that apply *only* to C++.
  668.  
  669. * Menu:
  670.  
  671. * Statement Exprs::     Putting statements and declarations inside expressions.
  672. * Local Labels::        Labels local to a statement-expression.
  673. * Labels as Values::    Getting pointers to labels, and computed gotos.
  674. * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
  675. * Constructing Calls::    Dispatching a call to another function.
  676. * Naming Types::        Giving a name to the type of some expression.
  677. * Typeof::              `typeof': referring to the type of an expression.
  678. * Lvalues::             Using `?:', `,' and casts in lvalues.
  679. * Conditionals::        Omitting the middle operand of a `?:' expression.
  680. * Long Long::        Double-word integers--`long long int'.
  681. * Zero Length::         Zero-length arrays.
  682. * Variable Length::     Arrays whose length is computed at run time.
  683. * Macro Varargs::    Macros with variable number of arguments.
  684. * Subscripting::        Any array can be subscripted, even if not an lvalue.
  685. * Pointer Arith::       Arithmetic on `void'-pointers and function pointers.
  686. * Initializers::        Non-constant initializers.
  687. * Constructors::        Constructor expressions give structures, unions
  688.                          or arrays as values.
  689. * Labeled Elements::    Labeling elements of initializers.
  690. * Cast to Union::       Casting to union type from any member of the union.
  691. * Case Ranges::        `case 1 ... 9' and such.
  692. * Function Attributes:: Declaring that functions have no side effects,
  693.                          or that they can never return.
  694. * Function Prototypes:: Prototype declarations and old-style definitions.
  695. * Dollar Signs::        Dollar sign is allowed in identifiers.
  696. * Character Escapes::   `\e' stands for the character ESC.
  697. * Variable Attributes::    Specifying attributes of variables.
  698. * Alignment::           Inquiring about the alignment of a type or variable.
  699. * Inline::              Defining inline functions (as fast as macros).
  700. * Extended Asm::        Assembler instructions with C expressions as operands.
  701.                          (With them you can define "built-in" functions.)
  702. * Asm Labels::          Specifying the assembler name to use for a C symbol.
  703. * Explicit Reg Vars::   Defining variables residing in specified registers.
  704. * Alternate Keywords::  `__const__', `__asm__', etc., for header files.
  705. * Incomplete Enums::    `enum foo;', with details to follow.
  706. * Function Names::    Printable strings which are the name of the current
  707.              function.
  708.  
  709. 
  710. File: gcc.info,  Node: Statement Exprs,  Next: Local Labels,  Up: C Extensions
  711.  
  712. Statements and Declarations in Expressions
  713. ==========================================
  714.  
  715.    A compound statement enclosed in parentheses may appear as an
  716. expression in GNU C.  This allows you to use loops, switches, and local
  717. variables within an expression.
  718.  
  719.    Recall that a compound statement is a sequence of statements
  720. surrounded by braces; in this construct, parentheses go around the
  721. braces.  For example:
  722.  
  723.      ({ int y = foo (); int z;
  724.         if (y > 0) z = y;
  725.         else z = - y;
  726.         z; })
  727.  
  728. is a valid (though slightly more complex than necessary) expression for
  729. the absolute value of `foo ()'.
  730.  
  731.    The last thing in the compound statement should be an expression
  732. followed by a semicolon; the value of this subexpression serves as the
  733. value of the entire construct.  (If you use some other kind of statement
  734. last within the braces, the construct has type `void', and thus
  735. effectively no value.)
  736.  
  737.    This feature is especially useful in making macro definitions "safe"
  738. (so that they evaluate each operand exactly once).  For example, the
  739. "maximum" function is commonly defined as a macro in standard C as
  740. follows:
  741.  
  742.      #define max(a,b) ((a) > (b) ? (a) : (b))
  743.  
  744. But this definition computes either A or B twice, with bad results if
  745. the operand has side effects.  In GNU C, if you know the type of the
  746. operands (here let's assume `int'), you can define the macro safely as
  747. follows:
  748.  
  749.      #define maxint(a,b) \
  750.        ({int _a = (a), _b = (b); _a > _b ? _a : _b; })
  751.  
  752.    Embedded statements are not allowed in constant expressions, such as
  753. the value of an enumeration constant, the width of a bit field, or the
  754. initial value of a static variable.
  755.  
  756.    If you don't know the type of the operand, you can still do this,
  757. but you must use `typeof' (*note Typeof::.) or type naming (*note
  758. Naming Types::.).
  759.  
  760. 
  761. File: gcc.info,  Node: Local Labels,  Next: Labels as Values,  Prev: Statement Exprs,  Up: C Extensions
  762.  
  763. Locally Declared Labels
  764. =======================
  765.  
  766.    Each statement expression is a scope in which "local labels" can be
  767. declared.  A local label is simply an identifier; you can jump to it
  768. with an ordinary `goto' statement, but only from within the statement
  769. expression it belongs to.
  770.  
  771.    A local label declaration looks like this:
  772.  
  773.      __label__ LABEL;
  774.  
  775. or
  776.  
  777.      __label__ LABEL1, LABEL2, ...;
  778.  
  779.    Local label declarations must come at the beginning of the statement
  780. expression, right after the `({', before any ordinary declarations.
  781.  
  782.    The label declaration defines the label *name*, but does not define
  783. the label itself.  You must do this in the usual way, with `LABEL:',
  784. within the statements of the statement expression.
  785.  
  786.    The local label feature is useful because statement expressions are
  787. often used in macros.  If the macro contains nested loops, a `goto' can
  788. be useful for breaking out of them.  However, an ordinary label whose
  789. scope is the whole function cannot be used: if the macro can be
  790. expanded several times in one function, the label will be multiply
  791. defined in that function.  A local label avoids this problem.  For
  792. example:
  793.  
  794.      #define SEARCH(array, target)                     \
  795.      ({                                               \
  796.        __label__ found;                                \
  797.        typeof (target) _SEARCH_target = (target);      \
  798.        typeof (*(array)) *_SEARCH_array = (array);     \
  799.        int i, j;                                       \
  800.        int value;                                      \
  801.        for (i = 0; i < max; i++)                       \
  802.          for (j = 0; j < max; j++)                     \
  803.            if (_SEARCH_array[i][j] == _SEARCH_target)  \
  804.              { value = i; goto found; }              \
  805.        value = -1;                                     \
  806.       found:                                           \
  807.        value;                                          \
  808.      })
  809.  
  810. 
  811. File: gcc.info,  Node: Labels as Values,  Next: Nested Functions,  Prev: Local Labels,  Up: C Extensions
  812.  
  813. Labels as Values
  814. ================
  815.  
  816.    You can get the address of a label defined in the current function
  817. (or a containing function) with the unary operator `&&'.  The value has
  818. type `void *'.  This value is a constant and can be used wherever a
  819. constant of that type is valid.  For example:
  820.  
  821.      void *ptr;
  822.      ...
  823.      ptr = &&foo;
  824.  
  825.    To use these values, you need to be able to jump to one.  This is
  826. done with the computed goto statement(1), `goto *EXP;'.  For example,
  827.  
  828.      goto *ptr;
  829.  
  830. Any expression of type `void *' is allowed.
  831.  
  832.    One way of using these constants is in initializing a static array
  833. that will serve as a jump table:
  834.  
  835.      static void *array[] = { &&foo, &&bar, &&hack };
  836.  
  837.    Then you can select a label with indexing, like this:
  838.  
  839.      goto *array[i];
  840.  
  841. Note that this does not check whether the subscript is in bounds--array
  842. indexing in C never does that.
  843.  
  844.    Such an array of label values serves a purpose much like that of the
  845. `switch' statement.  The `switch' statement is cleaner, so use that
  846. rather than an array unless the problem does not fit a `switch'
  847. statement very well.
  848.  
  849.    Another use of label values is in an interpreter for threaded code.
  850. The labels within the interpreter function can be stored in the
  851. threaded code for super-fast dispatching.
  852.  
  853.    You can use this mechanism to jump to code in a different function.
  854. If you do that, totally unpredictable things will happen.  The best way
  855. to avoid this is to store the label address only in automatic variables
  856. and never pass it as an argument.
  857.  
  858.    ---------- Footnotes ----------
  859.  
  860.    (1)  The analogous feature in Fortran is called an assigned goto,
  861. but that name seems inappropriate in C, where one can do more than
  862. simply store label addresses in label variables.
  863.  
  864. 
  865. File: gcc.info,  Node: Nested Functions,  Next: Constructing Calls,  Prev: Labels as Values,  Up: C Extensions
  866.  
  867. Nested Functions
  868. ================
  869.  
  870.    A "nested function" is a function defined inside another function.
  871. (Nested functions are not supported for GNU C++.)  The nested function's
  872. name is local to the block where it is defined.  For example, here we
  873. define a nested function named `square', and call it twice:
  874.  
  875.      foo (double a, double b)
  876.      {
  877.        double square (double z) { return z * z; }
  878.      
  879.        return square (a) + square (b);
  880.      }
  881.  
  882.    The nested function can access all the variables of the containing
  883. function that are visible at the point of its definition.  This is
  884. called "lexical scoping".  For example, here we show a nested function
  885. which uses an inherited variable named `offset':
  886.  
  887.      bar (int *array, int offset, int size)
  888.      {
  889.        int access (int *array, int index)
  890.          { return array[index + offset]; }
  891.        int i;
  892.        ...
  893.        for (i = 0; i < size; i++)
  894.          ... access (array, i) ...
  895.      }
  896.  
  897.    Nested function definitions must appear in the same part of a
  898. function as variable definitions; that is, before the first line of
  899. code in the enclosing function.
  900.  
  901.    It is possible to call the nested function from outside the scope of
  902. its name by storing its address or passing the address to another
  903. function:
  904.  
  905.      hack (int *array, int size)
  906.      {
  907.        void store (int index, int value)
  908.          { array[index] = value; }
  909.      
  910.        intermediate (store, size);
  911.      }
  912.  
  913.    Here, the function `intermediate' receives the address of `store' as
  914. an argument.  If `intermediate' calls `store', the arguments given to
  915. `store' are used to store into `array'.  But this technique works only
  916. so long as the containing function (`hack', in this example) does not
  917. exit.  If you try to call the nested function through its address after
  918. the containing function has exited, all hell will break loose.
  919.  
  920.    GNU CC implements taking the address of a nested function using a
  921. technique called "trampolines".  A paper describing them is available
  922. from `maya.idiap.ch' in the file `pub/tmb/usenix88-lexic.ps.Z'.
  923.  
  924.    A nested function can jump to a label inherited from a containing
  925. function, provided the label was explicitly declared in the containing
  926. function (*note Local Labels::.).  Such a jump returns instantly to the
  927. containing function, exiting the nested function which did the `goto'
  928. and any intermediate functions as well.  Here is an example:
  929.  
  930.      bar (int *array, int offset, int size)
  931.      {
  932.        __label__ failure;
  933.        int access (int *array, int index)
  934.          {
  935.            if (index > size)
  936.              goto failure;
  937.            return array[index + offset];
  938.          }
  939.        int i;
  940.        ...
  941.        for (i = 0; i < size; i++)
  942.          ... access (array, i) ...
  943.        ...
  944.        return 0;
  945.      
  946.       /* Control comes here from `access'
  947.          if it detects an error.  */
  948.       failure:
  949.        return -1;
  950.      }
  951.  
  952.    A nested function always has internal linkage.  Declaring one with
  953. `extern' is erroneous.  If you need to declare the nested function
  954. before its definition, use `auto' (which is otherwise meaningless for
  955. function declarations).
  956.  
  957.      bar (int *array, int offset, int size)
  958.      {
  959.        __label__ failure;
  960.        auto int access (int *, int);
  961.        ...
  962.        int access (int *array, int index)
  963.          {
  964.            if (index > size)
  965.              goto failure;
  966.            return array[index + offset];
  967.          }
  968.        ...
  969.      }
  970.  
  971. 
  972. File: gcc.info,  Node: Constructing Calls,  Next: Naming Types,  Prev: Nested Functions,  Up: C Extensions
  973.  
  974. Constructing Function Calls
  975. ===========================
  976.  
  977.    Using the built-in functions described below, you can record the
  978. arguments a function received, and call another function with the same
  979. arguments, without knowing the number or types of the arguments.
  980.  
  981.    You can also record the return value of that function call, and
  982. later return that value, without knowing what data type the function
  983. tried to return (as long as your caller expects that data type).
  984.  
  985. `__builtin_apply_args ()'
  986.      This built-in function returns a pointer of type `void *' to data
  987.      describing how to perform a call with the same arguments as were
  988.      passed to the current function.
  989.  
  990.      The function saves the arg pointer register, structure value
  991.      address, and all registers that might be used to pass arguments to
  992.      a function into a block of memory allocated on the stack.  Then it
  993.      returns the address of that block.
  994.  
  995. `__builtin_apply (FUNCTION, ARGUMENTS, SIZE)'
  996.      This built-in function invokes FUNCTION (type `void (*)()') with a
  997.      copy of the parameters described by ARGUMENTS (type `void *') and
  998.      SIZE (type `int').
  999.  
  1000.      The value of ARGUMENTS should be the value returned by
  1001.      `__builtin_apply_args'.  The argument SIZE specifies the size of
  1002.      the stack argument data, in bytes.
  1003.  
  1004.      This function returns a pointer of type `void *' to data describing
  1005.      how to return whatever value was returned by FUNCTION.  The data
  1006.      is saved in a block of memory allocated on the stack.
  1007.  
  1008.      It is not always simple to compute the proper value for SIZE.  The
  1009.      value is used by `__builtin_apply' to compute the amount of data
  1010.      that should be pushed on the stack and copied from the incoming
  1011.      argument area.
  1012.  
  1013. `__builtin_return (RESULT)'
  1014.      This built-in function returns the value described by RESULT from
  1015.      the containing function.  You should specify, for RESULT, a value
  1016.      returned by `__builtin_apply'.
  1017.  
  1018. 
  1019. File: gcc.info,  Node: Naming Types,  Next: Typeof,  Prev: Constructing Calls,  Up: C Extensions
  1020.  
  1021. Naming an Expression's Type
  1022. ===========================
  1023.  
  1024.    You can give a name to the type of an expression using a `typedef'
  1025. declaration with an initializer.  Here is how to define NAME as a type
  1026. name for the type of EXP:
  1027.  
  1028.      typedef NAME = EXP;
  1029.  
  1030.    This is useful in conjunction with the statements-within-expressions
  1031. feature.  Here is how the two together can be used to define a safe
  1032. "maximum" macro that operates on any arithmetic type:
  1033.  
  1034.      #define max(a,b) \
  1035.        ({typedef _ta = (a), _tb = (b);  \
  1036.          _ta _a = (a); _tb _b = (b);     \
  1037.          _a > _b ? _a : _b; })
  1038.  
  1039.    The reason for using names that start with underscores for the local
  1040. variables is to avoid conflicts with variable names that occur within
  1041. the expressions that are substituted for `a' and `b'.  Eventually we
  1042. hope to design a new form of declaration syntax that allows you to
  1043. declare variables whose scopes start only after their initializers;
  1044. this will be a more reliable way to prevent such conflicts.
  1045.  
  1046. 
  1047. File: gcc.info,  Node: Typeof,  Next: Lvalues,  Prev: Naming Types,  Up: C Extensions
  1048.  
  1049. Referring to a Type with `typeof'
  1050. =================================
  1051.  
  1052.    Another way to refer to the type of an expression is with `typeof'.
  1053. The syntax of using of this keyword looks like `sizeof', but the
  1054. construct acts semantically like a type name defined with `typedef'.
  1055.  
  1056.    There are two ways of writing the argument to `typeof': with an
  1057. expression or with a type.  Here is an example with an expression:
  1058.  
  1059.      typeof (x[0](1))
  1060.  
  1061. This assumes that `x' is an array of functions; the type described is
  1062. that of the values of the functions.
  1063.  
  1064.    Here is an example with a typename as the argument:
  1065.  
  1066.      typeof (int *)
  1067.  
  1068. Here the type described is that of pointers to `int'.
  1069.  
  1070.    If you are writing a header file that must work when included in
  1071. ANSI C programs, write `__typeof__' instead of `typeof'.  *Note
  1072. Alternate Keywords::.
  1073.  
  1074.    A `typeof'-construct can be used anywhere a typedef name could be
  1075. used.  For example, you can use it in a declaration, in a cast, or
  1076. inside of `sizeof' or `typeof'.
  1077.  
  1078.    * This declares `y' with the type of what `x' points to.
  1079.  
  1080.           typeof (*x) y;
  1081.  
  1082.    * This declares `y' as an array of such values.
  1083.  
  1084.           typeof (*x) y[4];
  1085.  
  1086.    * This declares `y' as an array of pointers to characters:
  1087.  
  1088.           typeof (typeof (char *)[4]) y;
  1089.  
  1090.      It is equivalent to the following traditional C declaration:
  1091.  
  1092.           char *y[4];
  1093.  
  1094.      To see the meaning of the declaration using `typeof', and why it
  1095.      might be a useful way to write, let's rewrite it with these macros:
  1096.  
  1097.           #define pointer(T)  typeof(T *)
  1098.           #define array(T, N) typeof(T [N])
  1099.  
  1100.      Now the declaration can be rewritten this way:
  1101.  
  1102.           array (pointer (char), 4) y;
  1103.  
  1104.      Thus, `array (pointer (char), 4)' is the type of arrays of 4
  1105.      pointers to `char'.
  1106.  
  1107. 
  1108. File: gcc.info,  Node: Lvalues,  Next: Conditionals,  Prev: Typeof,  Up: C Extensions
  1109.  
  1110. Generalized Lvalues
  1111. ===================
  1112.  
  1113.    Compound expressions, conditional expressions and casts are allowed
  1114. as lvalues provided their operands are lvalues.  This means that you
  1115. can take their addresses or store values into them.
  1116.  
  1117.    For example, a compound expression can be assigned, provided the last
  1118. expression in the sequence is an lvalue.  These two expressions are
  1119. equivalent:
  1120.  
  1121.      (a, b) += 5
  1122.      a, (b += 5)
  1123.  
  1124.    Similarly, the address of the compound expression can be taken.
  1125. These two expressions are equivalent:
  1126.  
  1127.      &(a, b)
  1128.      a, &b
  1129.  
  1130.    A conditional expression is a valid lvalue if its type is not void
  1131. and the true and false branches are both valid lvalues.  For example,
  1132. these two expressions are equivalent:
  1133.  
  1134.      (a ? b : c) = 5
  1135.      (a ? b = 5 : (c = 5))
  1136.  
  1137.    A cast is a valid lvalue if its operand is an lvalue.  A simple
  1138. assignment whose left-hand side is a cast works by converting the
  1139. right-hand side first to the specified type, then to the type of the
  1140. inner left-hand side expression.  After this is stored, the value is
  1141. converted back to the specified type to become the value of the
  1142. assignment.  Thus, if `a' has type `char *', the following two
  1143. expressions are equivalent:
  1144.  
  1145.      (int)a = 5
  1146.      (int)(a = (char *)(int)5)
  1147.  
  1148.    An assignment-with-arithmetic operation such as `+=' applied to a
  1149. cast performs the arithmetic using the type resulting from the cast,
  1150. and then continues as in the previous case.  Therefore, these two
  1151. expressions are equivalent:
  1152.  
  1153.      (int)a += 5
  1154.      (int)(a = (char *)(int) ((int)a + 5))
  1155.  
  1156.    You cannot take the address of an lvalue cast, because the use of its
  1157. address would not work out coherently.  Suppose that `&(int)f' were
  1158. permitted, where `f' has type `float'.  Then the following statement
  1159. would try to store an integer bit-pattern where a floating point number
  1160. belongs:
  1161.  
  1162.      *&(int)f = 1;
  1163.  
  1164.    This is quite different from what `(int)f = 1' would do--that would
  1165. convert 1 to floating point and store it.  Rather than cause this
  1166. inconsistency, we think it is better to prohibit use of `&' on a cast.
  1167.  
  1168.    If you really do want an `int *' pointer with the address of `f',
  1169. you can simply write `(int *)&f'.
  1170.  
  1171. 
  1172. File: gcc.info,  Node: Conditionals,  Next: Long Long,  Prev: Lvalues,  Up: C Extensions
  1173.  
  1174. Conditionals with Omitted Operands
  1175. ==================================
  1176.  
  1177.    The middle operand in a conditional expression may be omitted.  Then
  1178. if the first operand is nonzero, its value is the value of the
  1179. conditional expression.
  1180.  
  1181.    Therefore, the expression
  1182.  
  1183.      x ? : y
  1184.  
  1185. has the value of `x' if that is nonzero; otherwise, the value of `y'.
  1186.  
  1187.    This example is perfectly equivalent to
  1188.  
  1189.      x ? x : y
  1190.  
  1191. In this simple case, the ability to omit the middle operand is not
  1192. especially useful.  When it becomes useful is when the first operand
  1193. does, or may (if it is a macro argument), contain a side effect.  Then
  1194. repeating the operand in the middle would perform the side effect
  1195. twice.  Omitting the middle operand uses the value already computed
  1196. without the undesirable effects of recomputing it.
  1197.  
  1198. 
  1199. File: gcc.info,  Node: Long Long,  Next: Zero Length,  Prev: Conditionals,  Up: C Extensions
  1200.  
  1201. Double-Word Integers
  1202. ====================
  1203.  
  1204.    GNU C supports data types for integers that are twice as long as
  1205. `long int'.  Simply write `long long int' for a signed integer, or
  1206. `unsigned long long int' for an unsigned integer.  To make an integer
  1207. constant of type `long long int', add the suffix `LL' to the integer.
  1208. To make an integer constant of type `unsigned long long int', add the
  1209. suffix `ULL' to the integer.
  1210.  
  1211.    You can use these types in arithmetic like any other integer types.
  1212. Addition, subtraction, and bitwise boolean operations on these types
  1213. are open-coded on all types of machines.  Multiplication is open-coded
  1214. if the machine supports fullword-to-doubleword a widening multiply
  1215. instruction.  Division and shifts are open-coded only on machines that
  1216. provide special support.  The operations that are not open-coded use
  1217. special library routines that come with GNU CC.
  1218.  
  1219.    There may be pitfalls when you use `long long' types for function
  1220. arguments, unless you declare function prototypes.  If a function
  1221. expects type `int' for its argument, and you pass a value of type `long
  1222. long int', confusion will result because the caller and the subroutine
  1223. will disagree about the number of bytes for the argument.  Likewise, if
  1224. the function expects `long long int' and you pass `int'.  The best way
  1225. to avoid such problems is to use prototypes.
  1226.  
  1227.