🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #605

calling C++ from C

#605
From: John T Riedl
Date: Tue, 21 Nov 1989 03:10
21 lines
1177 bytes
I need to call a g++ routine from a C routine.  I'm having trouble
getting the constructors for external objects called correctly.  It
works fine for g++-1.35 using the g++ linker, since this linker
manages initialization through symbol "__start" defined in crt0+.o.

Under g++-1.36 initialization is handled differently.  When the
compiler recognizes that it is compiling 'main' it compiles in a call
to __main as the first statement of the procedure.  ___main is defined
in libg++.a(gnulib3.o), and handles calling the constructors.

My problem is finding an elegant method for invoking ___main
correctly.  So far the best I've been able to do is to to explicitly
call ___main from my C main program.

Are there better solutions?

Thanks,
John
-- 
John Riedl
{ucbvax,decvax,hplabs}!purdue!riedl  -or-  riedl@cs.purdue.edu
Technical Details
Message-ID: <8692@medusa.cs.purdue.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!purdue!riedl

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!purdue!riedl
From: riedl@cs.purdue.EDU (John T Riedl)
Newsgroups: gnu.g++.bug
Subject: calling C++ from C
Message-ID: <8692@medusa.cs.purdue.edu>
Date: 21 Nov 89 03:10:39 GMT
Distribution: gnu
Organization: Department of Computer Science, Purdue University
Lines: 21