Related articles |
---|
C++ linking v.s. C deneb_r@efn.org (1995-12-19) |
Re: C++ linking v.s. C dcf@hpesdcf.fc.hp.com (1995-12-20) |
From: | dcf@hpesdcf.fc.hp.com (David Fletcher) |
Newsgroups: | comp.compilers |
Date: | 20 Dec 1995 11:38:48 -0500 |
Organization: | Hewlett Packard - Ft. Collins |
References: | 95-12-115 |
Keywords: | C, C++, linker |
deneb_r@efn.org (Nathan A. Yoffa) writes:
> My question is the folllowing: To what degree does using CC
> for this link produce different code (if any).....
and the moderator noted:
> Every C and C++ compiler I know use a common linker. I'd be
> astonished if the code changed, though it's possible you might
> find yourself using C++ libraries where you used to use C
> libraries.
Note that with (many) cfront-based C++ compilers you have to make sure
that the main() routine is compiled with the C++ compiler. This is
needed so that static/global constructors and destructors get called.
Basically, the C++ compiler renames the original main() routine to
_main(), and then adds a new version of main() similar to the
following:
int main(int arc, char** argv, char** envp)
{
// ... code to call static/global constructors goes here...
int ReturnVal = _main(argc, argv, envp);
// ... code to call static/global destructors goes here...
return ReturnVal;
]
As long as you do not include anything that has a static/global
constructor or destructor your code should be fine (apart from the
fact that, on some systems, the run-time libraries are different from
those used with plain ol' C --- these differ with less frequency on
modern systems).
Hope this helps.
--
------------------------------------------------------------------------
David Fletcher dcf@fc.hp.com
ESL, Hewlett-Packard
Ft. Collins, CO
1.970.229.4970 (voice)
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.