🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Eugene Radchenko Fri, 06 Oct 1995 18:54
Global object initialization again
#2139
Author: Eugene Radchenko
Date: Fri, 06 Oct 1995 18:54
34 lines
2288 bytes
Hello people!
I would like to learn more about the proposal by German ISO representative
allowing (partial) programmer control of the inter-file initialization
order. This would be a very useful feature, especially in designs where you
need some server object in one module to be initialized before other
modules can access it.

Schwartz counters help here, but there are the situations where they are
insufficient. E.g. server initialization in module A calls the function
which dynamically selects the type of server object, creates it (using
new) and returns the pointer. For some types, it needs to access another
server from module B. But there is no way (short of #including B-module
header in A-module header where it is otherwise unnecessary) to ensure that
B-server gets initialized prior to A-server.

Techniques relying on static zero-initialization and/or local static
objects initialized upon function entry also do not solve the problem, as
servers requiring non-trivial init often need non-trivial shutdown as well
- in exactly the same environment. While my compiler (BC++ 4.0) at least
does strange things to order of local static objects cleanup.

            Best regards                        Genie

--
--------------------------------------------------------------------
Eugene V. Radchenko           Graduate Student in Computer Chemistry
E-mail: eugene@qsar.chem.msu.su                Fax: +7-(095)939-0290 
Ordinary mail:  Chair of Organic Chemistry, Department of Chemistry,
                      Moscow State University, 119899 Moscow, Russia
*****************  Disappearances are deceptive  *******************
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Global object initialization again
#2145
Author: Kalyan Kolachala
Date: Sat, 07 Oct 1995 07:39
17 lines
1111 bytes
A related and more intractable problem is that of the order of
initialization of statics in template classes. There is simply no
solution as there is no way of knowing what type the template class
will be instantiated with.

The only workaround I know of is not to use static data members in
template and instead put the statics within a member function.

I was wondering if there is any solution for this in the proposed
template compilation model.

Thanks,
Kalyan
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads