home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!wirzeniu
- From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
- Newsgroups: comp.lang.c
- Subject: Re: linking gcc code with CC code
- Keywords: link
- Message-ID: <1992Jul30.204044.2989@klaava.Helsinki.FI>
- Date: 30 Jul 92 20:40:44 GMT
- References: <1992Jul30.182047.18971@news.columbia.edu>
- Organization: University of Helsinki
- Lines: 28
-
- kps@cunixb.cc.columbia.edu (Karthik P Sheka) writes:
- >Is it possible to link gcc created object files with CC created object
- >files?
-
- That depends on which CC and which version gcc and which operating
- system and on the phase of the moon. Cross-language calling is always
- dependent on these (and other) factors, even for closely related
- languages such as C and C++. You can't even be certain that you can
- call subroutines in the same language, if they are compiled with
- different compilers (or even using different settings with the same
- compiler).
-
- Could you translate everything to C or C++ and use only one compiler?
- This is often the easiest solution.
-
- >I've tried doing so but it seems that the c functions cannot call
- >the c++ functions,
-
- Probably not. C++ names are usually mangled so that type information
- (needed for overloading) is encoded into the name (as the linker sees
- it). However, your sample code shows that there may be other problems
- as well: routine2 is declared (and defined) static in one file and
- extern in an other. I assume you meant that both declarations refer to
- the same function, so you have to change the static declaration and
- definition to be global (just remove the statics).
-
- --
- Lars.Wirzenius@helsinki.fi
-