home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
- From: torek@horse.ee.lbl.gov (Chris Torek)
- Newsgroups: comp.lang.c
- Subject: Re: gcc and cc!
- Message-ID: <27267@dog.ee.lbl.gov>
- Date: 6 Nov 92 11:39:47 GMT
- References: <1dctt2INNkbi@function.mps.ohio-state.edu>
- Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
- Organization: Lawrence Berkeley Laboratory, Berkeley
- Lines: 42
- NNTP-Posting-Host: 128.3.112.15
-
- In article <1dctt2INNkbi@function.mps.ohio-state.edu>
- ren@function.mps.ohio-state.edu (Liming Ren) writes:
- >It seems to me that if we have two object file , say foo.o and bar.o,
- >one is compiled with gcc and the other with cc, then we can't link them
- >together .... Could some experts say more about this.
-
- This is *extremely* implementation-dependent.
-
- Every C compiler author must make decisions about the mapping from
- C source code to machine concepts and instruction set. For most
- current machines, much of this mapping is obvious and straightforward,
- so that two compiler authors, working completely independently, are
- likely to come up with compatible schemes.
-
- There are some notable exceptions:
-
- Whether string literals wind up in read-only storage.
-
- Stack frame layout (e.g., whether to waste a register on a
- frame pointer, and where arguments go).
-
- Structure arguments and return values.
-
- Variable argument lists (printf() et al).
-
- Alloca. (Strictly speaking, this is not a `real' C function,
- but most implementations provide it anyway.)
-
- Object file formats, including symbol table formats.
-
- If you can avoid any dependence on these---the last one is impossible
- ---you will usually be able to intermix different compiler objects.
-
- In the specific case of GCC, GCC itself is typically compiled with,
- and/or tries to work with, each vendor's default implementation. This
- tends to remove some of the above obstacles. One that is likely to
- remain, and to affect user code, is the one dealing with structures.
- GCC provides a huge collection of special-purpose options, such as
- `-fpcc-struct-return' and `-msoft-float', to help work around these.
- --
- In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
- Berkeley, CA Domain: torek@ee.lbl.gov
-