This section lists various difficulties encountered in using GNU C or GNU C++ together with other compilers or with the assemblers, linkers, libraries and debuggers on certain systems.
This effect is intentional, to protect you from more subtle problems. Compilers differ as to many internal details of C++ implementation, including: how class instances are laid out, how multiple inheritance is implemented, and how virtual function calls are handled. If the name encoding were made the same, your programs would link against libraries provided from other compilers---but the programs would then crash when run. Incompatible libraries are then detected at link time, rather than at run time.
/bin/as
'.
-I/usr/include
' may cause trouble.
Many systems come with header files that won't work with GNU CC unless
corrected by fixincludes
. The corrected header files go in a new
directory; GNU CC searches this directory before `/usr/include
'.
If you use `-I/usr/include
', this tells GNU CC to search
`/usr/include
' earlier on, before the corrected headers. The
result is that you get the uncorrected header files.
Instead, you should use these options (when compiling C programs):
-I/usr/local/lib/gcc-lib/target/version/include -I/usr/include
For C++ programs, GNU CC also uses a special directory that defines C++ interfaces to standard C subroutines. This directory is meant to be searched before other standard include directories, so that it takes precedence. If you are compiling C++ programs and specifying include directories explicitly, use this option first, then the two options above:
-I/usr/local/lib/g++-include
-lgl_s
' as an option,
it gets translated magically to `-lgl_s -lX11_s -lc_s
'.
Naturally, this does not happen when you use GNU CC.
You must specify all three options explicitly.
double
on an 8-byte
boundary, and it expects every double
to be so aligned. The Sun
compiler usually gives double
values 8-byte alignment, with one
exception: function arguments of type double
may not be aligned.
As a result, if a function compiled with Sun CC takes the address of an
argument of type double
and passes this pointer of type
double *
to a function compiled with GNU CC, dereferencing the
pointer may cause a fatal signal.
One way to solve this problem is to compile your entire program with GNU
CC. Another solution is to modify the function that is compiled with
Sun CC to copy the argument into a local variable; local variables
are always properly aligned. A third solution is to modify the function
that uses the pointer to dereference it via the following function
access_double
instead of directly with `*
':
inline double access_double (double *unaligned_ptr) { union d2i { double d; int i[2]; }; union d2i *p = (union d2i *) unaligned_ptr; union d2i u; u.i[0] = p->i[0]; u.i[1] = p->i[1]; return u.d; }
Storing into the pointer can be done likewise with the same union.
malloc
function in the `libmalloc.a
' library
may allocate memory that is only 4 byte aligned. Since GNU CC on the
Sparc assumes that doubles are 8 byte aligned, this may result in a
fatal signal if doubles are stored in memory allocated by the
`libmalloc.a
' library.
The solution is to not use the `libmalloc.a
' library. Use instead
malloc
and related functions from `libc.a
'; they do not have
this problem.
This happens if you are using the GNU linker, because it does only static linking and looks only for unshared libraries. If you have a shared library with no unshared counterpart, the GNU linker won't find anything.
We hope to make a linker which supports Sun shared libraries, but please don't ask when it will be finished---we don't know.
libdl.a
' with some
versions of SunOS (mainly 4.1). This results in undefined symbols when
linking static binaries (that is, if you use `-static
'). If you
see undefined symbols _dlclose
, _dlsym
or _dlopen
when linking, compile and link against the file
`mit/util/misc/dlsym.c
' from the MIT version of X windows.
cc
does not
compile GNU CC correctly. We do not yet know why. However, GNU CC
compiled on earlier HP-UX versions works properly on HP-UX 9.01 and can
compile itself properly on 9.01.
alloca
or variable-size arrays. This is because GNU CC doesn't
generate HP-UX unwind descriptors for such functions. It may even be
impossible to generate them.
-g
') is not supported on the HP PA machine, unless you use
the preliminary GNU tools (see Installation).
(warning) Use of GR3 when frame >= 8192 may cause conflict.
These warnings are harmless and can be safely ignored.
/bin/as
') for the RS/6000
has certain problems that prevent the `-g
' option in GCC from
working. Note that `Makefile.in
' uses `-g
' by default when
compiling `libgcc2.c
'.
IBM has produced a fixed version of the assembler. The upgraded
assembler unfortunately was not included in any of the AIX 3.2 update
PTF releases (3.2.2, 3.2.3, or 3.2.3e). Users of AIX 3.1 should request
PTF U403044 from IBM and users of AIX 3.2 should request PTF U416277.
See the file `README.RS6000
' for more details on these updates.
You can test for the presense of a fixed assembler by using the command
as -u < /dev/null
If the command exits normally, the assembler fix already is installed. If the assembler complains that "-u" is an unknown flag, you need to order the fix.
extern int foo; ... foo ... static int foo;
will cause the linker to report an undefined symbol foo
.
Although this behavior differs from most other systems, it is not a
bug because redefining an extern
variable as static
is undefined in ANSI C.
-fdollars-in-identifiers
',
you cannot successfully use `$
' in identifiers on the RS/6000 due
to a restriction in the IBM assembler. GAS supports these
identifiers.
jump.c
'. XLC
version 1.3.0.1 or later fixes this problem. You can obtain XLC-1.3.0.2
by requesting PTF 421749 from IBM.
fldcr
' instruction is used. GNU CC uses
`fldcr
' on the 88100 to serialize volatile memory references. Use
the option `-mno-serialize-volatile
' if your version of the
assembler has this bug.
stddef.h
'
and `sys/types.h
', you get an error because there are two typedefs
of size_t
. You should change `sys/types.h
' by adding these
lines around the definition of size_t
:
#ifndef _SIZE_T #define _SIZE_T actual typedef here #endif
-mhc-struct-return
' to tell GNU CC to use a convention compatible
with it.
GNU CC uses the same convention as the Ultrix C compiler. You can use these options to produce code compatible with the Fortran compiler:
-fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
-L/usr/local/lib/gcc-lib/we32k-att-sysv/2.6.0 -lgcc -lc_s
The first specifies where to find the library `libgcc.a
'
specified with the `-lgcc
' option.
GNU CC does linking by invoking ld
, just as cc
does, and
there is no reason why it should matter which compilation program
you use to invoke ld
. If someone tracks this problem down,
it can probably be fixed easily.
ecvt
, fcvt
and gcvt
. Given valid
floating point numbers, they sometimes print `NaN
'.
Or use the `-noasmopt
' option when you compile GNU CC with itself,
and then again when you compile your program. (This is a temporary
kludge to turn off assembler optimization on Irix.) If this proves to
be what you need, edit the assembler spec in the file `specs
' so
that it unconditionally passes `-O0
' to the assembler, and never
passes `-O2
' or `-O3
'.