Dave said:
[...]
I specifically want to stay within the realm of Standard C++. I don't want
to do anything compiler-specific. I probably should not have mentioned the
words "dynamic library" since their presence naturally tends to cause people
to think I'm looking for something platform-specific even though my stated
intent was the opposite.
But you'd not be getting the best advice on a platform-specific feature,
if you try to look for non-platform-specific mechanism to do something
with a platform-specific element (dynamic libraries in this case). No,
I am not encouraging you to seek platform-specific advice here. Just
trying to indicate the issues with your approach.
Don't get us wrong, please.
So, let's pose the problem this way:
I need to ensure that a given function is called upon program startup before
control is transferred to main().
Just to be totally generic, loading of a dynamic library doesn't
necessarily happen before 'main' is called. See 'dlopen' or 'LoadLibrary'
or whatever it is on your platform.
And, yes, as a very beginner-level C++ test question, "how to call
a function before 'main' is given control" is something we can answer,
and, besides, you had answered it in your original post.
I would like to solicit suggestions on
ways I may accomplish this that fall strictly within the standard
language.
That's the problem WW was trying to indicate: there are no dlls in the
standard language. So, now you're switching from a particular problem to
a generic problem, and a solution to the latter is not necessarily
an acceptable solution to the former.
I'm looking for creative / varied ways to accomplish this as a means of 1)
Possibly improving the code I'm maintaining;
Staying within confines of the standard language and library may not be
an improvement in that case. Using proper OS-specific mechanisms might.
Consider yourself warned.
2) Expanding my knowledge of
C++.
That never hurts, of course.
V