Article View: gnu.g++.help
Article #87order of initialization
From: Ed Barton
Date: Fri, 07 Aug 1992 08:36
Date: Fri, 07 Aug 1992 08:36
31 lines
1627 bytes
1627 bytes
In current C++ systems, it is difficult or impossible to get control of the order of global initializations. In many implementations, the order can be influenced by changing the order of the object files, but it is difficult to apply this hack when some of the object files come out of a library and others come from the user's code. I have heard that this topic is being discussed by the C++ standards people, and that eventually there may be some solution. In the meantime, are there any #pragmas in g++ that will allow the programmer to influence the order of global constructors between different files? If there are not any, I plan to implement a fairly stupid scheme in my copy of g++. The scheme would work as follows: Modify the compiler to recognize #pragma initialization_order 10004 in a C++ source file, and cause it to influence the name of the file function so that the initialization order number is encoded in the name. Modify collect to recognized these encoded order numbers when they occur, and to sort the file functions by ascending order number, with initializations that have no number coming last. Although the scheme is trivial, its implementation may not be, because I am not a g++ expert. Please let me know if there is already something that will work. Thanks for any suggestions.
Technical Details
Message-ID:
<EB.92Aug7083601@ascent.ascent.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ascent!ebShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help Path: arc1-ca.pugleaf.net!sparky!uunet!ascent!eb From: eb@ascent.com (Ed Barton) Subject: order of initialization Message-ID: <EB.92Aug7083601@ascent.ascent.com> Date: 7 Aug 92 08:36:01 Organization: Ascent Technology, Inc., Cambridge Massachusetts Lines: 35