Re: Execution of a function on startup
From: Dave (better_cs_now_at_yahoo.com)
Date: 01/19/05
- Next message: Dave: "Re: Execution of a function on startup"
- Previous message: Siemel Naran: "Re: Designing a Matrix class"
- In reply to: Victor Bazarov: "Re: Execution of a function on startup"
- Next in thread: Victor Bazarov: "Re: Execution of a function on startup"
- Reply: Victor Bazarov: "Re: Execution of a function on startup"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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!
- Next message: Dave: "Re: Execution of a function on startup"
- Previous message: Siemel Naran: "Re: Designing a Matrix class"
- In reply to: Victor Bazarov: "Re: Execution of a function on startup"
- Next in thread: Victor Bazarov: "Re: Execution of a function on startup"
- Reply: Victor Bazarov: "Re: Execution of a function on startup"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|