home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / gcc.info-11 (.txt) < prev    next >
GNU Info File  |  1996-06-29  |  50KB  |  871 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  5. Boston, MA 02111-1307 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software
  7. Foundation, Inc.
  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.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided also
  13. that the sections entitled "GNU General Public License," "Funding for
  14. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  15. included exactly as in the original, and provided that the entire
  16. resulting derived work is distributed under the terms of a permission
  17. notice identical to this one.
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that the sections entitled "GNU General Public
  21. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  22. `Look And Feel'", and this permission notice, may be included in
  23. translations approved by the Free Software Foundation instead of in the
  24. original English.
  25. File: gcc.info,  Node: Installation Problems,  Next: Cross-Compiler Problems,  Prev: Actual Bugs,  Up: Trouble
  26. Installation Problems
  27. =====================
  28.    This is a list of problems (and some apparent problems which don't
  29. really mean anything is wrong) that show up during installation of GNU
  30.    * On certain systems, defining certain environment variables such as
  31.      `CC' can interfere with the functioning of `make'.
  32.    * If you encounter seemingly strange errors when trying to build the
  33.      compiler in a directory other than the source directory, it could
  34.      be because you have previously configured the compiler in the
  35.      source directory.  Make sure you have done all the necessary
  36.      preparations.  *Note Other Dir::.
  37.    * If you build GNU CC on a BSD system using a directory stored in a
  38.      System V file system, problems may occur in running `fixincludes'
  39.      if the System V file system doesn't support symbolic links.  These
  40.      problems result in a failure to fix the declaration of `size_t' in
  41.      `sys/types.h'.  If you find that `size_t' is a signed type and
  42.      that type mismatches occur, this could be the cause.
  43.      The solution is not to use such a directory for building GNU CC.
  44.    * In previous versions of GNU CC, the `gcc' driver program looked for
  45.      `as' and `ld' in various places; for example, in files beginning
  46.      with `/usr/local/lib/gcc-'.  GNU CC version 2 looks for them in
  47.      the directory `/usr/local/lib/gcc-lib/TARGET/VERSION'.
  48.      Thus, to use a version of `as' or `ld' that is not the system
  49.      default, for example `gas' or GNU `ld', you must put them in that
  50.      directory (or make links to them from that directory).
  51.    * Some commands executed when making the compiler may fail (return a
  52.      non-zero status) and be ignored by `make'.  These failures, which
  53.      are often due to files that were not found, are expected, and can
  54.      safely be ignored.
  55.    * It is normal to have warnings in compiling certain files about
  56.      unreachable code and about enumeration type clashes.  These files'
  57.      names begin with `insn-'.  Also, `real.c' may get some warnings
  58.      that you can ignore.
  59.    * Sometimes `make' recompiles parts of the compiler when installing
  60.      the compiler.  In one case, this was traced down to a bug in
  61.      `make'.  Either ignore the problem or switch to GNU Make.
  62.    * If you have installed a program known as purify, you may find that
  63.      it causes errors while linking `enquire', which is part of building
  64.      GNU CC.  The fix is to get rid of the file `real-ld' which purify
  65.      installs--so that GNU CC won't try to use it.
  66.    * On SLS 1.01, a Linux-based GNU system, there is a problem with
  67.      `libc.a': it does not contain the obstack functions.  However, GNU
  68.      CC assumes that the obstack functions are in `libc.a' when it is
  69.      the GNU C library.  To work around this problem, change the
  70.      `__GNU_LIBRARY__' conditional around line 31 to `#if 1'.
  71.    * On some 386 systems, building the compiler never finishes because
  72.      `enquire' hangs due to a hardware problem in the motherboard--it
  73.      reports floating point exceptions to the kernel incorrectly.  You
  74.      can install GNU CC except for `float.h' by patching out the
  75.      command to run `enquire'.  You may also be able to fix the problem
  76.      for real by getting a replacement motherboard.  This problem was
  77.      observed in Revision E of the Micronics motherboard, and is fixed
  78.      in Revision F.  It has also been observed in the MYLEX MXA-33
  79.      motherboard.
  80.      If you encounter this problem, you may also want to consider
  81.      removing the FPU from the socket during the compilation.
  82.      Alternatively, if you are running SCO Unix, you can reboot and
  83.      force the FPU to be ignored.  To do this, type `hd(40)unix auto
  84.      ignorefpu'.
  85.    * On some 386 systems, GNU CC crashes trying to compile `enquire.c'.
  86.      This happens on machines that don't have a 387 FPU chip.  On 386
  87.      machines, the system kernel is supposed to emulate the 387 when you
  88.      don't have one.  The crash is due to a bug in the emulator.
  89.      One of these systems is the Unix from Interactive Systems: 386/ix.
  90.      On this system, an alternate emulator is provided, and it does
  91.      work.  To use it, execute this command as super-user:
  92.           ln /etc/emulator.rel1 /etc/emulator
  93.      and then reboot the system.  (The default emulator file remains
  94.      present under the name `emulator.dflt'.)
  95.      Try using `/etc/emulator.att', if you have such a problem on the
  96.      SCO system.
  97.      Another system which has this problem is Esix.  We don't know
  98.      whether it has an alternate emulator that works.
  99.      On NetBSD 0.8, a similar problem manifests itself as these error
  100.      messages:
  101.           enquire.c: In function `fprop':
  102.           enquire.c:2328: floating overflow
  103.    * On SCO systems, when compiling GNU CC with the system's compiler,
  104.      do not use `-O'.  Some versions of the system's compiler miscompile
  105.      GNU CC with `-O'.
  106.    * Sometimes on a Sun 4 you may observe a crash in the program
  107.      `genflags' or `genoutput' while building GNU CC.  This is said to
  108.      be due to a bug in `sh'.  You can probably get around it by running
  109.      `genflags' or `genoutput' manually and then retrying the `make'.
  110.    * On Solaris 2, executables of GNU CC version 2.0.2 are commonly
  111.      available, but they have a bug that shows up when compiling current
  112.      versions of GNU CC: undefined symbol errors occur during assembly
  113.      if you use `-g'.
  114.      The solution is to compile the current version of GNU CC without
  115.      `-g'.  That makes a working compiler which you can use to recompile
  116.      with `-g'.
  117.    * Solaris 2 comes with a number of optional OS packages.  Some of
  118.      these packages are needed to use GNU CC fully.  If you did not
  119.      install all optional packages when installing Solaris, you will
  120.      need to verify that the packages that GNU CC needs are installed.
  121.      To check whether an optional package is installed, use the
  122.      `pkginfo' command.  To add an optional package, use the `pkgadd'
  123.      command.  For further details, see the Solaris documentation.
  124.      For Solaris 2.0 and 2.1, GNU CC needs six packages: `SUNWarc',
  125.      `SUNWbtool', `SUNWesu', `SUNWhea', `SUNWlibm', and `SUNWtoo'.
  126.      For Solaris 2.2, GNU CC needs an additional seventh package:
  127.      `SUNWsprot'.
  128.    * On Solaris 2, trying to use the linker and other tools in
  129.      `/usr/ucb' to install GNU CC has been observed to cause trouble.
  130.      For example, the linker may hang indefinitely.  The fix is to
  131.      remove `/usr/ucb' from your `PATH'.
  132.    * If you use the 1.31 version of the MIPS assembler (such as was
  133.      shipped with Ultrix 3.1), you will need to use the
  134.      -fno-delayed-branch switch when optimizing floating point code.
  135.      Otherwise, the assembler will complain when the GCC compiler fills
  136.      a branch delay slot with a floating point instruction, such as
  137.      `add.d'.
  138.    * If on a MIPS system you get an error message saying "does not have
  139.      gp sections for all it's [sic] sectons [sic]", don't worry about
  140.      it.  This happens whenever you use GAS with the MIPS linker, but
  141.      there is not really anything wrong, and it is okay to use the
  142.      output file.  You can stop such warnings by installing the GNU
  143.      linker.
  144.      It would be nice to extend GAS to produce the gp tables, but they
  145.      are optional, and there should not be a warning about their
  146.      absence.
  147.    * In Ultrix 4.0 on the MIPS machine, `stdio.h' does not work with GNU
  148.      CC at all unless it has been fixed with `fixincludes'.  This causes
  149.      problems in building GNU CC.  Once GNU CC is installed, the
  150.      problems go away.
  151.      To work around this problem, when making the stage 1 compiler,
  152.      specify this option to Make:
  153.           GCC_FOR_TARGET="./xgcc -B./ -I./include"
  154.      When making stage 2 and stage 3, specify this option:
  155.           CFLAGS="-g -I./include"
  156.    * Users have reported some problems with version 2.0 of the MIPS
  157.      compiler tools that were shipped with Ultrix 4.1.  Version 2.10
  158.      which came with Ultrix 4.2 seems to work fine.
  159.      Users have also reported some problems with version 2.20 of the
  160.      MIPS compiler tools that were shipped with RISC/os 4.x.  The
  161.      earlier version 2.11 seems to work fine.
  162.    * Some versions of the MIPS linker will issue an assertion failure
  163.      when linking code that uses `alloca' against shared libraries on
  164.      RISC-OS 5.0, and DEC's OSF/1 systems.  This is a bug in the
  165.      linker, that is supposed to be fixed in future revisions.  To
  166.      protect against this, GNU CC passes `-non_shared' to the linker
  167.      unless you pass an explicit `-shared' or `-call_shared' switch.
  168.    * On System V release 3, you may get this error message while
  169.      linking:
  170.           ld fatal: failed to write symbol name SOMETHING
  171.            in strings table for file WHATEVER
  172.      This probably indicates that the disk is full or your ULIMIT won't
  173.      allow the file to be as large as it needs to be.
  174.      This problem can also result because the kernel parameter `MAXUMEM'
  175.      is too small.  If so, you must regenerate the kernel and make the
  176.      value much larger.  The default value is reported to be 1024; a
  177.      value of 32768 is said to work.  Smaller values may also work.
  178.    * On System V, if you get an error like this,
  179.           /usr/local/lib/bison.simple: In function `yyparse':
  180.           /usr/local/lib/bison.simple:625: virtual memory exhausted
  181.      that too indicates a problem with disk space, ULIMIT, or `MAXUMEM'.
  182.    * Current GNU CC versions probably do not work on version 2 of the
  183.      NeXT operating system.
  184.    * On NeXTStep 3.0, the Objective C compiler does not work, due,
  185.      apparently, to a kernel bug that it happens to trigger.  This
  186.      problem does not happen on 3.1.
  187.    * On the Tower models 4N0 and 6N0, by default a process is not
  188.      allowed to have more than one megabyte of memory.  GNU CC cannot
  189.      compile itself (or many other programs) with `-O' in that much
  190.      memory.
  191.      To solve this problem, reconfigure the kernel adding the following
  192.      line to the configuration file:
  193.           MAXUMEM = 4096
  194.    * On HP 9000 series 300 or 400 running HP-UX release 8.0, there is a
  195.      bug in the assembler that must be fixed before GNU CC can be
  196.      built.  This bug manifests itself during the first stage of
  197.      compilation, while building `libgcc2.a':
  198.           _floatdisf
  199.           cc1: warning: `-g' option not supported on this version of GCC
  200.           cc1: warning: `-g1' option not supported on this version of GCC
  201.           ./xgcc: Internal compiler error: program as got fatal signal 11
  202.      A patched version of the assembler is available by anonymous ftp
  203.      from `altdorf.ai.mit.edu' as the file
  204.      `archive/cph/hpux-8.0-assembler'.  If you have HP software support,
  205.      the patch can also be obtained directly from HP, as described in
  206.      the following note:
  207.           This is the patched assembler, to patch SR#1653-010439, where
  208.           the assembler aborts on floating point constants.
  209.           The bug is not really in the assembler, but in the shared
  210.           library version of the function "cvtnum(3c)".  The bug on
  211.           "cvtnum(3c)" is SR#4701-078451.  Anyway, the attached
  212.           assembler uses the archive library version of "cvtnum(3c)"
  213.           and thus does not exhibit the bug.
  214.      This patch is also known as PHCO_4484.
  215.    * On HP-UX version 8.05, but not on 8.07 or more recent versions,
  216.      the `fixproto' shell script triggers a bug in the system shell.
  217.      If you encounter this problem, upgrade your operating system or
  218.      use BASH (the GNU shell) to run `fixproto'.
  219.    * Some versions of the Pyramid C compiler are reported to be unable
  220.      to compile GNU CC.  You must use an older version of GNU CC for
  221.      bootstrapping.  One indication of this problem is if you get a
  222.      crash when GNU CC compiles the function `muldi3' in file
  223.      `libgcc2.c'.
  224.      You may be able to succeed by getting GNU CC version 1, installing
  225.      it, and using it to compile GNU CC version 2.  The bug in the
  226.      Pyramid C compiler does not seem to affect GNU CC version 1.
  227.    * There may be similar problems on System V Release 3.1 on 386
  228.      systems.
  229.    * On the Intel Paragon (an i860 machine), if you are using operating
  230.      system version 1.0, you will get warnings or errors about
  231.      redefinition of `va_arg' when you build GNU CC.
  232.      If this happens, then you need to link most programs with the
  233.      library `iclib.a'.  You must also modify `stdio.h' as follows:
  234.      before the lines
  235.           #if     defined(__i860__) && !defined(_VA_LIST)
  236.           #include <va_list.h>
  237.      insert the line
  238.           #if __PGC__
  239.      and after the lines
  240.           extern int  vprintf(const char *, va_list );
  241.           extern int  vsprintf(char *, const char *, va_list );
  242.           #endif
  243.      insert the line
  244.           #endif /* __PGC__ */
  245.      These problems don't exist in operating system version 1.1.
  246.    * On the Altos 3068, programs compiled with GNU CC won't work unless
  247.      you fix a kernel bug.  This happens using system versions V.2.2
  248.      1.0gT1 and V.2.2 1.0e and perhaps later versions as well.  See the
  249.      file `README.ALTOS'.
  250.    * You will get several sorts of compilation and linking errors on the
  251.      we32k if you don't follow the special instructions.  *Note
  252.      Configurations::.
  253.    * A bug in the HP-UX 8.05 (and earlier) shell will cause the fixproto
  254.      program to report an error of the form:
  255.           ./fixproto: sh internal 1K buffer overflow
  256.      To fix this, change the first line of the fixproto script to look
  257.      like:
  258.           #!/bin/ksh
  259. File: gcc.info,  Node: Cross-Compiler Problems,  Next: Interoperation,  Prev: Installation Problems,  Up: Trouble
  260. Cross-Compiler Problems
  261. =======================
  262.    You may run into problems with cross compilation on certain machines,
  263. for several reasons.
  264.    * Cross compilation can run into trouble for certain machines because
  265.      some target machines' assemblers require floating point numbers to
  266.      be written as *integer* constants in certain contexts.
  267.      The compiler writes these integer constants by examining the
  268.      floating point value as an integer and printing that integer,
  269.      because this is simple to write and independent of the details of
  270.      the floating point representation.  But this does not work if the
  271.      compiler is running on a different machine with an incompatible
  272.      floating point format, or even a different byte-ordering.
  273.      In addition, correct constant folding of floating point values
  274.      requires representing them in the target machine's format.  (The C
  275.      standard does not quite require this, but in practice it is the
  276.      only way to win.)
  277.      It is now possible to overcome these problems by defining macros
  278.      such as `REAL_VALUE_TYPE'.  But doing so is a substantial amount of
  279.      work for each target machine.  *Note Cross-compilation::.
  280.    * At present, the program `mips-tfile' which adds debug support to
  281.      object files on MIPS systems does not work in a cross compile
  282.      environment.
  283. File: gcc.info,  Node: Interoperation,  Next: External Bugs,  Prev: Cross-Compiler Problems,  Up: Trouble
  284. Interoperation
  285. ==============
  286.    This section lists various difficulties encountered in using GNU C or
  287. GNU C++ together with other compilers or with the assemblers, linkers,
  288. libraries and debuggers on certain systems.
  289.    * Objective C does not work on the RS/6000.
  290.    * GNU C++ does not do name mangling in the same way as other C++
  291.      compilers.  This means that object files compiled with one compiler
  292.      cannot be used with another.
  293.      This effect is intentional, to protect you from more subtle
  294.      problems.  Compilers differ as to many internal details of C++
  295.      implementation, including: how class instances are laid out, how
  296.      multiple inheritance is implemented, and how virtual function
  297.      calls are handled.  If the name encoding were made the same, your
  298.      programs would link against libraries provided from other
  299.      compilers--but the programs would then crash when run.
  300.      Incompatible libraries are then detected at link time, rather than
  301.      at run time.
  302.    * Older GDB versions sometimes fail to read the output of GNU CC
  303.      version 2.  If you have trouble, get GDB version 4.4 or later.
  304.    * DBX rejects some files produced by GNU CC, though it accepts
  305.      similar constructs in output from PCC.  Until someone can supply a
  306.      coherent description of what is valid DBX input and what is not,
  307.      there is nothing I can do about these problems.  You are on your
  308.      own.
  309.    * The GNU assembler (GAS) does not support PIC.  To generate PIC
  310.      code, you must use some other assembler, such as `/bin/as'.
  311.    * On some BSD systems, including some versions of Ultrix, use of
  312.      profiling causes static variable destructors (currently used only
  313.      in C++) not to be run.
  314.    * Use of `-I/usr/include' may cause trouble.
  315.      Many systems come with header files that won't work with GNU CC
  316.      unless corrected by `fixincludes'.  The corrected header files go
  317.      in a new directory; GNU CC searches this directory before
  318.      `/usr/include'.  If you use `-I/usr/include', this tells GNU CC to
  319.      search `/usr/include' earlier on, before the corrected headers.
  320.      The result is that you get the uncorrected header files.
  321.      Instead, you should use these options (when compiling C programs):
  322.           -I/usr/local/lib/gcc-lib/TARGET/VERSION/include -I/usr/include
  323.      For C++ programs, GNU CC also uses a special directory that
  324.      defines C++ interfaces to standard C subroutines.  This directory
  325.      is meant to be searched *before* other standard include
  326.      directories, so that it takes precedence.  If you are compiling
  327.      C++ programs and specifying include directories explicitly, use
  328.      this option first, then the two options above:
  329.           -I/usr/local/lib/g++-include
  330.    * On some SGI systems, when you use `-lgl_s' as an option, it gets
  331.      translated magically to `-lgl_s -lX11_s -lc_s'.  Naturally, this
  332.      does not happen when you use GNU CC.  You must specify all three
  333.      options explicitly.
  334.    * On a Sparc, GNU CC aligns all values of type `double' on an 8-byte
  335.      boundary, and it expects every `double' to be so aligned.  The Sun
  336.      compiler usually gives `double' values 8-byte alignment, with one
  337.      exception: function arguments of type `double' may not be aligned.
  338.      As a result, if a function compiled with Sun CC takes the address
  339.      of an argument of type `double' and passes this pointer of type
  340.      `double *' to a function compiled with GNU CC, dereferencing the
  341.      pointer may cause a fatal signal.
  342.      One way to solve this problem is to compile your entire program
  343.      with GNU CC.  Another solution is to modify the function that is
  344.      compiled with Sun CC to copy the argument into a local variable;
  345.      local variables are always properly aligned.  A third solution is
  346.      to modify the function that uses the pointer to dereference it via
  347.      the following function `access_double' instead of directly with
  348.      `*':
  349.           inline double
  350.           access_double (double *unaligned_ptr)
  351.           {
  352.             union d2i { double d; int i[2]; };
  353.           
  354.             union d2i *p = (union d2i *) unaligned_ptr;
  355.             union d2i u;
  356.           
  357.             u.i[0] = p->i[0];
  358.             u.i[1] = p->i[1];
  359.           
  360.             return u.d;
  361.           }
  362.      Storing into the pointer can be done likewise with the same union.
  363.    * On Solaris, the `malloc' function in the `libmalloc.a' library may
  364.      allocate memory that is only 4 byte aligned.  Since GNU CC on the
  365.      Sparc assumes that doubles are 8 byte aligned, this may result in a
  366.      fatal signal if doubles are stored in memory allocated by the
  367.      `libmalloc.a' library.
  368.      The solution is to not use the `libmalloc.a' library.  Use instead
  369.      `malloc' and related functions from `libc.a'; they do not have
  370.      this problem.
  371.    * Sun forgot to include a static version of `libdl.a' with some
  372.      versions of SunOS (mainly 4.1).  This results in undefined symbols
  373.      when linking static binaries (that is, if you use `-static').  If
  374.      you see undefined symbols `_dlclose', `_dlsym' or `_dlopen' when
  375.      linking, compile and link against the file `mit/util/misc/dlsym.c'
  376.      from the MIT version of X windows.
  377.    * The 128-bit long double format that the Sparc port supports
  378.      currently works by using the architecturally defined quad-word
  379.      floating point instructions.  Since there is no hardware that
  380.      supports these instructions they must be emulated by the operating
  381.      system.  Long doubles do not work in Sun OS versions 4.0.3 and
  382.      earlier, because the kernel emulator uses an obsolete and
  383.      incompatible format.  Long doubles do not work in Sun OS version
  384.      4.1.1 due to a problem in a Sun library.  Long doubles do work on
  385.      Sun OS versions 4.1.2 and higher, but GNU CC does not enable them
  386.      by default.  Long doubles appear to work in Sun OS 5.x (Solaris
  387.      2.x).
  388.    * On HP-UX version 9.01 on the HP PA, the HP compiler `cc' does not
  389.      compile GNU CC correctly.  We do not yet know why.  However, GNU CC
  390.      compiled on earlier HP-UX versions works properly on HP-UX 9.01
  391.      and can compile itself properly on 9.01.
  392.    * On the HP PA machine, ADB sometimes fails to work on functions
  393.      compiled with GNU CC.  Specifically, it fails to work on functions
  394.      that use `alloca' or variable-size arrays.  This is because GNU CC
  395.      doesn't generate HP-UX unwind descriptors for such functions.  It
  396.      may even be impossible to generate them.
  397.    * Debugging (`-g') is not supported on the HP PA machine, unless you
  398.      use the preliminary GNU tools (*note Installation::.).
  399.    * Taking the address of a label may generate errors from the HP-UX
  400.      PA assembler.  GAS for the PA does not have this problem.
  401.    * Using floating point parameters for indirect calls to static
  402.      functions will not work when using the HP assembler.  There simply
  403.      is no way for GCC to specify what registers hold arguments for
  404.      static functions when using the HP assembler.  GAS for the PA does
  405.      not have this problem.
  406.    * In extremely rare cases involving some very large functions you may
  407.      receive errors from the HP linker complaining about an out of
  408.      bounds unconditional branch offset.  This used to occur more often
  409.      in previous versions of GNU CC, but is now exceptionally rare.  If
  410.      you should run into it, you can work around by making your
  411.      function smaller.
  412.    * GNU CC compiled code sometimes emits warnings from the HP-UX
  413.      assembler of the form:
  414.           (warning) Use of GR3 when
  415.             frame >= 8192 may cause conflict.
  416.      These warnings are harmless and can be safely ignored.
  417.    * The current version of the assembler (`/bin/as') for the RS/6000
  418.      has certain problems that prevent the `-g' option in GCC from
  419.      working.  Note that `Makefile.in' uses `-g' by default when
  420.      compiling `libgcc2.c'.
  421.      IBM has produced a fixed version of the assembler.  The upgraded
  422.      assembler unfortunately was not included in any of the AIX 3.2
  423.      update PTF releases (3.2.2, 3.2.3, or 3.2.3e).  Users of AIX 3.1
  424.      should request PTF U403044 from IBM and users of AIX 3.2 should
  425.      request PTF U416277.  See the file `README.RS6000' for more
  426.      details on these updates.
  427.      You can test for the presense of a fixed assembler by using the
  428.      command
  429.           as -u < /dev/null
  430.      If the command exits normally, the assembler fix already is
  431.      installed.  If the assembler complains that "-u" is an unknown
  432.      flag, you need to order the fix.
  433.    * On the IBM RS/6000, compiling code of the form
  434.           extern int foo;
  435.           
  436.           ... foo ...
  437.           
  438.           static int foo;
  439.      will cause the linker to report an undefined symbol `foo'.
  440.      Although this behavior differs from most other systems, it is not a
  441.      bug because redefining an `extern' variable as `static' is
  442.      undefined in ANSI C.
  443.    * AIX on the RS/6000 provides support (NLS) for environments outside
  444.      of the United States.  Compilers and assemblers use NLS to support
  445.      locale-specific representations of various objects including
  446.      floating-point numbers ("." vs "," for separating decimal
  447.      fractions).  There have been problems reported where the library
  448.      linked with GCC does not produce the same floating-point formats
  449.      that the assembler accepts.  If you have this problem, set the
  450.      LANG environment variable to "C" or "En_US".
  451.    * Even if you specify `-fdollars-in-identifiers', you cannot
  452.      successfully use `$' in identifiers on the RS/6000 due to a
  453.      restriction in the IBM assembler.  GAS supports these identifiers.
  454.    * On the RS/6000, XLC version 1.3.0.0 will miscompile `jump.c'.  XLC
  455.      version 1.3.0.1 or later fixes this problem.  You can obtain
  456.      XLC-1.3.0.2 by requesting PTF 421749 from IBM.
  457.    * There is an assembler bug in versions of DG/UX prior to 5.4.2.01
  458.      that occurs when the `fldcr' instruction is used.  GNU CC uses
  459.      `fldcr' on the 88100 to serialize volatile memory references.  Use
  460.      the option `-mno-serialize-volatile' if your version of the
  461.      assembler has this bug.
  462.    * On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
  463.      messages from the linker.  These warning messages complain of
  464.      mismatched psect attributes.  You can ignore them.  *Note VMS
  465.      Install::.
  466.    * On NewsOS version 3, if you include both of the files `stddef.h'
  467.      and `sys/types.h', you get an error because there are two typedefs
  468.      of `size_t'.  You should change `sys/types.h' by adding these
  469.      lines around the definition of `size_t':
  470.           #ifndef _SIZE_T
  471.           #define _SIZE_T
  472.           ACTUAL TYPEDEF HERE
  473.           #endif
  474.    * On the Alliant, the system's own convention for returning
  475.      structures and unions is unusual, and is not compatible with GNU
  476.      CC no matter what options are used.
  477.    * On the IBM RT PC, the MetaWare HighC compiler (hc) uses a different
  478.      convention for structure and union returning.  Use the option
  479.      `-mhc-struct-return' to tell GNU CC to use a convention compatible
  480.      with it.
  481.    * On Ultrix, the Fortran compiler expects registers 2 through 5 to
  482.      be saved by function calls.  However, the C compiler uses
  483.      conventions compatible with BSD Unix: registers 2 through 5 may be
  484.      clobbered by function calls.
  485.      GNU CC uses the same convention as the Ultrix C compiler.  You can
  486.      use these options to produce code compatible with the Fortran
  487.      compiler:
  488.           -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
  489.    * On the WE32k, you may find that programs compiled with GNU CC do
  490.      not work with the standard shared C library.  You may need to link
  491.      with the ordinary C compiler.  If you do so, you must specify the
  492.      following options:
  493.           -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.7.1 -lgcc -lc_s
  494.      The first specifies where to find the library `libgcc.a' specified
  495.      with the `-lgcc' option.
  496.      GNU CC does linking by invoking `ld', just as `cc' does, and there
  497.      is no reason why it *should* matter which compilation program you
  498.      use to invoke `ld'.  If someone tracks this problem down, it can
  499.      probably be fixed easily.
  500.    * On the Alpha, you may get assembler errors about invalid syntax as
  501.      a result of floating point constants.  This is due to a bug in the
  502.      C library functions `ecvt', `fcvt' and `gcvt'.  Given valid
  503.      floating point numbers, they sometimes print `NaN'.
  504.    * On Irix 4.0.5F (and perhaps in some other versions), an assembler
  505.      bug sometimes reorders instructions incorrectly when optimization
  506.      is turned on.  If you think this may be happening to you, try
  507.      using the GNU assembler; GAS version 2.1 supports ECOFF on Irix.
  508.      Or use the `-noasmopt' option when you compile GNU CC with itself,
  509.      and then again when you compile your program.  (This is a temporary
  510.      kludge to turn off assembler optimization on Irix.)  If this
  511.      proves to be what you need, edit the assembler spec in the file
  512.      `specs' so that it unconditionally passes `-O0' to the assembler,
  513.      and never passes `-O2' or `-O3'.
  514. File: gcc.info,  Node: External Bugs,  Next: Incompatibilities,  Prev: Interoperation,  Up: Trouble
  515. Problems Compiling Certain Programs
  516. ===================================
  517.    Certain programs have problems compiling.
  518.    * Parse errors may occur compiling X11 on a Decstation running
  519.      Ultrix 4.2 because of problems in DEC's versions of the X11 header
  520.      files `X11/Xlib.h' and `X11/Xutil.h'.  People recommend adding
  521.      `-I/usr/include/mit' to use the MIT versions of the header files,
  522.      using the `-traditional' switch to turn off ANSI C, or fixing the
  523.      header files by adding this:
  524.           #ifdef __STDC__
  525.           #define NeedFunctionPrototypes 0
  526.           #endif
  527.    * If you have trouble compiling Perl on a SunOS 4 system, it may be
  528.      because Perl specifies `-I/usr/ucbinclude'.  This accesses the
  529.      unfixed header files.  Perl specifies the options
  530.           -traditional -Dvolatile=__volatile__
  531.           -I/usr/include/sun -I/usr/ucbinclude
  532.           -fpcc-struct-return
  533.      most of which are unnecessary with GCC 2.4.5 and newer versions.
  534.      You can make a properly working Perl by setting `ccflags' to
  535.      `-fwritable-strings' (implied by the `-traditional' in the
  536.      original options) and `cppflags' to empty in `config.sh', then
  537.      typing `./doSH; make depend; make'.
  538.    * On various 386 Unix systems derived from System V, including SCO,
  539.      ISC, and ESIX, you may get error messages about running out of
  540.      virtual memory while compiling certain programs.
  541.      You can prevent this problem by linking GNU CC with the GNU malloc
  542.      (which thus replaces the malloc that comes with the system).  GNU
  543.      malloc is available as a separate package, and also in the file
  544.      `src/gmalloc.c' in the GNU Emacs 19 distribution.
  545.      If you have installed GNU malloc as a separate library package,
  546.      use this option when you relink GNU CC:
  547.           MALLOC=/usr/local/lib/libgmalloc.a
  548.      Alternatively, if you have compiled `gmalloc.c' from Emacs 19, copy
  549.      the object file to `gmalloc.o' and use this option when you relink
  550.      GNU CC:
  551.           MALLOC=gmalloc.o
  552. File: gcc.info,  Node: Incompatibilities,  Next: Fixed Headers,  Prev: External Bugs,  Up: Trouble
  553. Incompatibilities of GNU CC
  554. ===========================
  555.    There are several noteworthy incompatibilities between GNU C and most
  556. existing (non-ANSI) versions of C.  The `-traditional' option
  557. eliminates many of these incompatibilities, *but not all*, by telling
  558. GNU C to behave like the other C compilers.
  559.    * GNU CC normally makes string constants read-only.  If several
  560.      identical-looking string constants are used, GNU CC stores only one
  561.      copy of the string.
  562.      One consequence is that you cannot call `mktemp' with a string
  563.      constant argument.  The function `mktemp' always alters the string
  564.      its argument points to.
  565.      Another consequence is that `sscanf' does not work on some systems
  566.      when passed a string constant as its format control string or
  567.      input.  This is because `sscanf' incorrectly tries to write into
  568.      the string constant.  Likewise `fscanf' and `scanf'.
  569.      The best solution to these problems is to change the program to use
  570.      `char'-array variables with initialization strings for these
  571.      purposes instead of string constants.  But if this is not possible,
  572.      you can use the `-fwritable-strings' flag, which directs GNU CC to
  573.      handle string constants the same way most C compilers do.
  574.      `-traditional' also has this effect, among others.
  575.    * `-2147483648' is positive.
  576.      This is because 2147483648 cannot fit in the type `int', so
  577.      (following the ANSI C rules) its data type is `unsigned long int'.
  578.      Negating this value yields 2147483648 again.
  579.    * GNU CC does not substitute macro arguments when they appear inside
  580.      of string constants.  For example, the following macro in GNU CC
  581.           #define foo(a) "a"
  582.      will produce output `"a"' regardless of what the argument A is.
  583.      The `-traditional' option directs GNU CC to handle such cases
  584.      (among others) in the old-fashioned (non-ANSI) fashion.
  585.    * When you use `setjmp' and `longjmp', the only automatic variables
  586.      guaranteed to remain valid are those declared `volatile'.  This is
  587.      a consequence of automatic register allocation.  Consider this
  588.      function:
  589.           jmp_buf j;
  590.           
  591.           foo ()
  592.           {
  593.             int a, b;
  594.           
  595.             a = fun1 ();
  596.             if (setjmp (j))
  597.               return a;
  598.           
  599.             a = fun2 ();
  600.             /* `longjmp (j)' may occur in `fun3'. */
  601.             return a + fun3 ();
  602.           }
  603.      Here `a' may or may not be restored to its first value when the
  604.      `longjmp' occurs.  If `a' is allocated in a register, then its
  605.      first value is restored; otherwise, it keeps the last value stored
  606.      in it.
  607.      If you use the `-W' option with the `-O' option, you will get a
  608.      warning when GNU CC thinks such a problem might be possible.
  609.      The `-traditional' option directs GNU C to put variables in the
  610.      stack by default, rather than in registers, in functions that call
  611.      `setjmp'.  This results in the behavior found in traditional C
  612.      compilers.
  613.    * Programs that use preprocessing directives in the middle of macro
  614.      arguments do not work with GNU CC.  For example, a program like
  615.      this will not work:
  616.           foobar (
  617.           #define luser
  618.                   hack)
  619.      ANSI C does not permit such a construct.  It would make sense to
  620.      support it when `-traditional' is used, but it is too much work to
  621.      implement.
  622.    * Declarations of external variables and functions within a block
  623.      apply only to the block containing the declaration.  In other
  624.      words, they have the same scope as any other declaration in the
  625.      same place.
  626.      In some other C compilers, a `extern' declaration affects all the
  627.      rest of the file even if it happens within a block.
  628.      The `-traditional' option directs GNU C to treat all `extern'
  629.      declarations as global, like traditional compilers.
  630.    * In traditional C, you can combine `long', etc., with a typedef
  631.      name, as shown here:
  632.           typedef int foo;
  633.           typedef long foo bar;
  634.      In ANSI C, this is not allowed: `long' and other type modifiers
  635.      require an explicit `int'.  Because this criterion is expressed by
  636.      Bison grammar rules rather than C code, the `-traditional' flag
  637.      cannot alter it.
  638.    * PCC allows typedef names to be used as function parameters.  The
  639.      difficulty described immediately above applies here too.
  640.    * PCC allows whitespace in the middle of compound assignment
  641.      operators such as `+='.  GNU CC, following the ANSI standard, does
  642.      not allow this.  The difficulty described immediately above
  643.      applies here too.
  644.    * GNU CC complains about unterminated character constants inside of
  645.      preprocessing conditionals that fail.  Some programs have English
  646.      comments enclosed in conditionals that are guaranteed to fail; if
  647.      these comments contain apostrophes, GNU CC will probably report an
  648.      error.  For example, this code would produce an error:
  649.           #if 0
  650.           You can't expect this to work.
  651.           #endif
  652.      The best solution to such a problem is to put the text into an
  653.      actual C comment delimited by `/*...*/'.  However, `-traditional'
  654.      suppresses these error messages.
  655.    * Many user programs contain the declaration `long time ();'.  In the
  656.      past, the system header files on many systems did not actually
  657.      declare `time', so it did not matter what type your program
  658.      declared it to return.  But in systems with ANSI C headers, `time'
  659.      is declared to return `time_t', and if that is not the same as
  660.      `long', then `long time ();' is erroneous.
  661.      The solution is to change your program to use `time_t' as the
  662.      return type of `time'.
  663.    * When compiling functions that return `float', PCC converts it to a
  664.      double.  GNU CC actually returns a `float'.  If you are concerned
  665.      with PCC compatibility, you should declare your functions to return
  666.      `double'; you might as well say what you mean.
  667.    * When compiling functions that return structures or unions, GNU CC
  668.      output code normally uses a method different from that used on most
  669.      versions of Unix.  As a result, code compiled with GNU CC cannot
  670.      call a structure-returning function compiled with PCC, and vice
  671.      versa.
  672.      The method used by GNU CC is as follows: a structure or union
  673.      which is 1, 2, 4 or 8 bytes long is returned like a scalar.  A
  674.      structure or union with any other size is stored into an address
  675.      supplied by the caller (usually in a special, fixed register, but
  676.      on some machines it is passed on the stack).  The
  677.      machine-description macros `STRUCT_VALUE' and
  678.      `STRUCT_INCOMING_VALUE' tell GNU CC where to pass this address.
  679.      By contrast, PCC on most target machines returns structures and
  680.      unions of any size by copying the data into an area of static
  681.      storage, and then returning the address of that storage as if it
  682.      were a pointer value.  The caller must copy the data from that
  683.      memory area to the place where the value is wanted.  GNU CC does
  684.      not use this method because it is slower and nonreentrant.
  685.      On some newer machines, PCC uses a reentrant convention for all
  686.      structure and union returning.  GNU CC on most of these machines
  687.      uses a compatible convention when returning structures and unions
  688.      in memory, but still returns small structures and unions in
  689.      registers.
  690.      You can tell GNU CC to use a compatible convention for all
  691.      structure and union returning with the option
  692.      `-fpcc-struct-return'.
  693.    * GNU C complains about program fragments such as `0x74ae-0x4000'
  694.      which appear to be two hexadecimal constants separated by the minus
  695.      operator.  Actually, this string is a single "preprocessing token".
  696.      Each such token must correspond to one token in C.  Since this
  697.      does not, GNU C prints an error message.  Although it may appear
  698.      obvious that what is meant is an operator and two values, the ANSI
  699.      C standard specifically requires that this be treated as erroneous.
  700.      A "preprocessing token" is a "preprocessing number" if it begins
  701.      with a digit and is followed by letters, underscores, digits,
  702.      periods and `e+', `e-', `E+', or `E-' character sequences.
  703.      To make the above program fragment valid, place whitespace in
  704.      front of the minus sign.  This whitespace will end the
  705.      preprocessing number.
  706. File: gcc.info,  Node: Fixed Headers,  Next: Standard Libraries,  Prev: Incompatibilities,  Up: Trouble
  707. Fixed Header Files
  708. ==================
  709.    GNU CC needs to install corrected versions of some system header
  710. files.  This is because most target systems have some header files that
  711. won't work with GNU CC unless they are changed.  Some have bugs, some
  712. are incompatible with ANSI C, and some depend on special features of
  713. other compilers.
  714.    Installing GNU CC automatically creates and installs the fixed header
  715. files, by running a program called `fixincludes' (or for certain
  716. targets an alternative such as `fixinc.svr4').  Normally, you don't
  717. need to pay attention to this.  But there are cases where it doesn't do
  718. the right thing automatically.
  719.    * If you update the system's header files, such as by installing a
  720.      new system version, the fixed header files of GNU CC are not
  721.      automatically updated.  The easiest way to update them is to
  722.      reinstall GNU CC.  (If you want to be clever, look in the makefile
  723.      and you can find a shortcut.)
  724.    * On some systems, in particular SunOS 4, header file directories
  725.      contain machine-specific symbolic links in certain places.  This
  726.      makes it possible to share most of the header files among hosts
  727.      running the same version of SunOS 4 on different machine models.
  728.      The programs that fix the header files do not understand this
  729.      special way of using symbolic links; therefore, the directory of
  730.      fixed header files is good only for the machine model used to
  731.      build it.
  732.      In SunOS 4, only programs that look inside the kernel will notice
  733.      the difference between machine models.  Therefore, for most
  734.      purposes, you need not be concerned about this.
  735.      It is possible to make separate sets of fixed header files for the
  736.      different machine models, and arrange a structure of symbolic
  737.      links so as to use the proper set, but you'll have to do this by
  738.      hand.
  739.    * On Lynxos, GNU CC by default does not fix the header files.  This
  740.      is because bugs in the shell cause the `fixincludes' script to
  741.      fail.
  742.      This means you will encounter problems due to bugs in the system
  743.      header files.  It may be no comfort that they aren't GNU CC's
  744.      fault, but it does mean that there's nothing for us to do about
  745.      them.
  746. File: gcc.info,  Node: Standard Libraries,  Next: Disappointments,  Prev: Fixed Headers,  Up: Trouble
  747. Standard Libraries
  748. ==================
  749.    GNU CC by itself attempts to be what the ISO/ANSI C standard calls a
  750. "conforming freestanding implementation".  This means all ANSI C
  751. language features are available, as well as the contents of `float.h',
  752. `limits.h', `stdarg.h', and `stddef.h'.  The rest of the C library is
  753. supplied by the vendor of the operating system.  If that C library
  754. doesn't conform to the C standards, then your programs might get
  755. warnings (especially when using `-Wall') that you don't expect.
  756.    For example, the `sprintf' function on SunOS 4.1.3 returns `char *'
  757. while the C standard says that `sprintf' returns an `int'.  The
  758. `fixincludes' program could make the prototype for this function match
  759. the Standard, but that would be wrong, since the function will still
  760. return `char *'.
  761.    If you need a Standard compliant library, then you need to find one,
  762. as GNU CC does not provide one.  The GNU C library (called `glibc') has
  763. been ported to a number of operating systems, and provides ANSI/ISO,
  764. POSIX, BSD and SystemV compatibility.  You could also ask your operating
  765. system vendor if newer libraries are available.
  766. File: gcc.info,  Node: Disappointments,  Next: C++ Misunderstandings,  Prev: Standard Libraries,  Up: Trouble
  767. Disappointments and Misunderstandings
  768. =====================================
  769.    These problems are perhaps regrettable, but we don't know any
  770. practical way around them.
  771.    * Certain local variables aren't recognized by debuggers when you
  772.      compile with optimization.
  773.      This occurs because sometimes GNU CC optimizes the variable out of
  774.      existence.  There is no way to tell the debugger how to compute the
  775.      value such a variable "would have had", and it is not clear that
  776.      would be desirable anyway.  So GNU CC simply does not mention the
  777.      eliminated variable when it writes debugging information.
  778.      You have to expect a certain amount of disagreement between the
  779.      executable and your source code, when you use optimization.
  780.    * Users often think it is a bug when GNU CC reports an error for code
  781.      like this:
  782.           int foo (struct mumble *);
  783.           
  784.           struct mumble { ... };
  785.           
  786.           int foo (struct mumble *x)
  787.           { ... }
  788.      This code really is erroneous, because the scope of `struct
  789.      mumble' in the prototype is limited to the argument list
  790.      containing it.  It does not refer to the `struct mumble' defined
  791.      with file scope immediately below--they are two unrelated types
  792.      with similar names in different scopes.
  793.      But in the definition of `foo', the file-scope type is used
  794.      because that is available to be inherited.  Thus, the definition
  795.      and the prototype do not match, and you get an error.
  796.      This behavior may seem silly, but it's what the ANSI standard
  797.      specifies.  It is easy enough for you to make your code work by
  798.      moving the definition of `struct mumble' above the prototype.
  799.      It's not worth being incompatible with ANSI C just to avoid an
  800.      error for the example shown above.
  801.    * Accesses to bitfields even in volatile objects works by accessing
  802.      larger objects, such as a byte or a word.  You cannot rely on what
  803.      size of object is accessed in order to read or write the bitfield;
  804.      it may even vary for a given bitfield according to the precise
  805.      usage.
  806.      If you care about controlling the amount of memory that is
  807.      accessed, use volatile but do not use bitfields.
  808.    * GNU CC comes with shell scripts to fix certain known problems in
  809.      system header files.  They install corrected copies of various
  810.      header files in a special directory where only GNU CC will
  811.      normally look for them.  The scripts adapt to various systems by
  812.      searching all the system header files for the problem cases that
  813.      we know about.
  814.      If new system header files are installed, nothing automatically
  815.      arranges to update the corrected header files.  You will have to
  816.      reinstall GNU CC to fix the new header files.  More specifically,
  817.      go to the build directory and delete the files `stmp-fixinc' and
  818.      `stmp-headers', and the subdirectory `include'; then do `make
  819.      install' again.
  820.    * On 68000 systems, you can get paradoxical results if you test the
  821.      precise values of floating point numbers.  For example, you can
  822.      find that a floating point value which is not a NaN is not equal
  823.      to itself.  This results from the fact that the the floating point
  824.      registers hold a few more bits of precision than fit in a `double'
  825.      in memory.  Compiled code moves values between memory and floating
  826.      point registers at its convenience, and moving them into memory
  827.      truncates them.
  828.      You can partially avoid this problem by using the `-ffloat-store'
  829.      option (*note Optimize Options::.).
  830.    * On the MIPS, variable argument functions using `varargs.h' cannot
  831.      have a floating point value for the first argument.  The reason
  832.      for this is that in the absence of a prototype in scope, if the
  833.      first argument is a floating point, it is passed in a floating
  834.      point register, rather than an integer register.
  835.      If the code is rewritten to use the ANSI standard `stdarg.h'
  836.      method of variable arguments, and the prototype is in scope at the
  837.      time of the call, everything will work fine.
  838. File: gcc.info,  Node: C++ Misunderstandings,  Next: Protoize Caveats,  Prev: Disappointments,  Up: Trouble
  839. Common Misunderstandings with GNU C++
  840. =====================================
  841.    C++ is a complex language and an evolving one, and its standard
  842. definition (the ANSI C++ draft standard) is also evolving.  As a result,
  843. your C++ compiler may occasionally surprise you, even when its behavior
  844. is correct.  This section discusses some areas that frequently give
  845. rise to questions of this sort.
  846. * Menu:
  847. * Static Definitions::  Static member declarations are not definitions
  848. * Temporaries::         Temporaries may vanish before you expect
  849. File: gcc.info,  Node: Static Definitions,  Next: Temporaries,  Up: C++ Misunderstandings
  850. Declare *and* Define Static Members
  851. -----------------------------------
  852.    When a class has static data members, it is not enough to *declare*
  853. the static member; you must also *define* it.  For example:
  854.      class Foo
  855.      {
  856.        ...
  857.        void method();
  858.        static int bar;
  859.      };
  860.    This declaration only establishes that the class `Foo' has an `int'
  861. named `Foo::bar', and a member function named `Foo::method'.  But you
  862. still need to define *both* `method' and `bar' elsewhere.  According to
  863. the draft ANSI standard, you must supply an initializer in one (and
  864. only one) source file, such as:
  865.      int Foo::bar = 0;
  866.    Other C++ compilers may not correctly implement the standard
  867. behavior.  As a result, when you switch to `g++' from one of these
  868. compilers, you may discover that a program that appeared to work
  869. correctly in fact does not conform to the standard: `g++' reports as
  870. undefined symbols any static data members that lack definitions.
  871.