public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Libraries and glocal constructors
@ 1998-04-24  9:07 Greg Galloway
  1998-04-24 16:23 ` H.J. Lu
  1998-04-24 23:55 ` Martin von Loewis
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Galloway @ 1998-04-24  9:07 UTC (permalink / raw)
  To: egcs

I've written a simulation library on top of PVM in C++ which I'm compiling
with EGCS 1.0.2.  The library has bindings for C, C++, FORTRAN, and Ada.
I intentionally stayed away from declaring any static global objects
which would need global constructors so that they library could be linked
with a non-C++ compiler.  I am using standard library classes string,
ifstream, ofstream, and various STL containers.  Any global objects are
new'd and accessed via a pointer.

Are there any global objects in the standard library which would still
require a global constructor/destructor which would not get initialized
properly when linked with a non-C++ compiler?

Is this addressed by the standard?  Is it library implementation dependent?

Thanks,
Greg
--
Gregory L. Galloway
Research Scientist I

http://eoeml.gtri.gatech.edu/home/gregg/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Libraries and glocal constructors
  1998-04-24  9:07 Libraries and glocal constructors Greg Galloway
@ 1998-04-24 16:23 ` H.J. Lu
  1998-04-24 23:55 ` Martin von Loewis
  1 sibling, 0 replies; 3+ messages in thread
From: H.J. Lu @ 1998-04-24 16:23 UTC (permalink / raw)
  To: Greg Galloway; +Cc: egcs

> 
> I've written a simulation library on top of PVM in C++ which I'm compiling
> with EGCS 1.0.2.  The library has bindings for C, C++, FORTRAN, and Ada.
> I intentionally stayed away from declaring any static global objects
> which would need global constructors so that they library could be linked
> with a non-C++ compiler.  I am using standard library classes string,
> ifstream, ofstream, and various STL containers.  Any global objects are
> new'd and accessed via a pointer.
> 
> Are there any global objects in the standard library which would still
> require a global constructor/destructor which would not get initialized
> properly when linked with a non-C++ compiler?
> 
> Is this addressed by the standard?  Is it library implementation dependent?

It is up to the library implementors to do it right. As for Linux and
maybe all ELF-based systems like Solaris, you don't have to worry about
the global constructors in the C++ libraries. They are handled by
ELF and gcc. You can link them against any languages you want. The
ELF and the gcc driver will make sure they do the right thing. My
ELF paper

ftp://sunsite.unc.edu/pub/Linux/GCC/elf.ps.gz

explains how it is done.


-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Libraries and glocal constructors
  1998-04-24  9:07 Libraries and glocal constructors Greg Galloway
  1998-04-24 16:23 ` H.J. Lu
@ 1998-04-24 23:55 ` Martin von Loewis
  1 sibling, 0 replies; 3+ messages in thread
From: Martin von Loewis @ 1998-04-24 23:55 UTC (permalink / raw)
  To: gregg; +Cc: egcs

> Are there any global objects in the standard library which would still
> require a global constructor/destructor which would not get initialized
> properly when linked with a non-C++ compiler?

Whether there are global objects depends on the library. On an ELF system
using GNU binutils, you can find out with

objdump --headers /usr/local/lib/libstdc++.a|grep ctor

Whether they would be initialized when linked with a non-C++ compiler
would depend on that compiler.

> Is this addressed by the standard?  

No. The standard talks about implementations of C++, not about
implementations of some other language. Furthermore, it doesn't know
the concept of a linking process, which is purely
implementation-defined (except for 'linkage', but this is an issue
different from 'lifetime').

> Is it library implementation dependent?

Definitely. Furthermore, it also depends on the compiler, the linker,
and the object file format.

Regards,
Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-04-24 23:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-24  9:07 Libraries and glocal constructors Greg Galloway
1998-04-24 16:23 ` H.J. Lu
1998-04-24 23:55 ` Martin von Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).