Re: Execution of a function on startup

From: Dave (better_cs_now_at_yahoo.com)
Date: 01/19/05


Date: Wed, 19 Jan 2005 12:21:58 -0700


"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:XdyHd.36510$NC6.31662@newsread1.mlpsca01.us.to.verio.net...
> Dave wrote:
> > [...]
> > 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

Please folks, forget the dynamic libs. They don't matter. They might as
well have never existed. The program I'm maintaining already works as it
is. I don't *need* another technique. I just *want* to identify creative
ways to invoke a function upon program startup, before main() is called,
because this is 99% an academic exercise to expand knowledge. If I happen
to find a technique that I like better than what's been done, I will use it,
but it is completely beside the point. To those so inclined towards
thinking of creative ways to use the language, I am giving you a friendly
challenge to exercise your C++ muscles and dazzle the NG with your
creativity / elegance!



Relevant Pages

  • Re: Execution of a function on startup
    ... > with a platform-specific element (dynamic libraries in this case). ... > I am not encouraging you to seek platform-specific advice here. ... > or whatever it is on your platform. ... > Staying within confines of the standard language and library may not be ...
    (comp.lang.cpp)
  • Re: Execution of a function on startup
    ... with a platform-specific element (dynamic libraries in this case). ... or whatever it is on your platform. ... > ways I may accomplish this that fall strictly within the standard language. ... > Possibly improving the code I'm maintaining; ...
    (comp.lang.cpp)
  • Re: how would you go about building this? (special thanks to dadiOH)
    ... > and especially thank you very much to dadiOH for such a thoughtful and ... Best advice I can give you now is to give it up...no way no how are you ... the platform, buy a second hand couch, whack the legs off and set it on ... ....a help file of info about MP3s, ...
    (rec.woodworking)
  • Re: Developing In XP OE then distributing to 98 OE users
    ... platform that you wish to distribute your software. ... and THEN creating the final distribution, ... exactly what the advice was telling you to avoid!). ... Edmonton, Alberta Canada ...
    (microsoft.public.access.devtoolkits)
  • Re: shared memory malloc library
    ... (Richard Tobin) ... Flash Gordon wrote: ... and the correct place to get advice on them is in the system specific ... And he got an answer "its platform specific, ...
    (comp.lang.c)