🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3462

standardizing routines without main()

#3462
From: Stephen Vavasis
Date: Thu, 15 Feb 1996 17:20
33 lines
2142 bytes
I would like to propose that the standard deal with the following
issue.  I would like to write a subroutine in C++ that gets called by
an existing program.  The subroutine might get loaded with a dynamic
loader into an already compiled program to which I, the C++
programmer, have no access.  I imagine other people have the same
situation.

In this case, there is no C++ main().  Nonetheless, I would still like
to use C++ features like global static data items whose constructors
and destructors get called.

To handle this, I would like to be able to put an explicit call like
"cpp_start()" at the entry point of the routine, and "cpp_finish()" at
the end that would take care of all the initialization/cleanup C++
normally does in main.  As programmer, I would take responsibility for
making sure that nothing is done before cpp_start() or after
cpp_finish().

In fact, some C++ implementations already offer such a call just for
this purpose.  See, for example,
     http://www.mathworks.com/1606.html
which describes how to write dynamically-loadable C++ subroutines for
matlab using the Watcom C++ compiler.

But as far as I know, the names of these start/finish calls are not
standardized, so I can't count on portability.

Thanks,
Steve Vavasis
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Technical Details
Message-ID: <4fvmd1$bh1@syn.cs.cornell.edu>
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
From: vavasis@CS.Cornell.EDU (Stephen Vavasis)
Newsgroups: comp.std.c++
Subject: standardizing routines without main()
Date: 15 Feb 1996 09:20:36 PST
Organization: Cornell Univ. CS Dept, Ithaca NY 14853
Approved: austern@isolde.mti.sgi.com
Message-ID: <4fvmd1$bh1@syn.cs.cornell.edu>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 15 Feb 1996 11:18:41 -0500
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMSNrcky4NqrwXLNJAQF7BwH8CwHHuGHYQhzMQPMpaMaPEAHKOh+qkgt6
 PvH5n0e9Xj9lZiUcA4zp+VK+BUyJdaTiEbZT2miYEAPO0WZ9nkBxGQ==
 =9o+A
Originator: austern@isolde.mti.sgi.com