--- In [email protected], "Paul Herring" <[EMAIL PROTECTED]> wrote:
>
> On 9/25/07, RAVI <[EMAIL PROTECTED]> wrote:
> > Hello everybody,
> >
> > I am writing an application where I will call my function first before
> > the executing the user's main function.
> > I would like to write my our main function from which the user main
> > function has to be called.
> >
> > i am trying to #define the main function like this:
> >
> > #define main(a,b) main(a,b){
> > my_Function();
> > user_main(argc,argv);
> > }
> > user_main(a,b)
> >
> >
> > This works fine if the user is writing his/her main function as
> > int main(int argc,char *argv[])
> > but what if the user is writng main function as
> > int main()
> > simply without any arguments.
> >
> > How do I #define the user main fuction so that any type of user main
> > function can be replaced .
>
> Your solution is wrong.
>
> Tell your users to write their function to match
>
> int user_function(int, char**)
>
> even if they don't intend to use them, and then you write
>
> int main(int argc, char** argv){
> your_function(argc, argv);
> return user_function(argc, argv);
> }
>
> and don't use the defines at all.
>
>
> --
> PJH
> "Statistics are like a bikini. What they reveal is suggestive, but
> what they conceal is vital"
> -- Aaron Levenstein
>
What if I am going to #define main function like this:
#define main(...) main(int argc,char *argv[])
{
my_function();
user_main(argc,argv);
}
user_main(int argc,char *argv)
Any drawbacks with this sort of solution?
--Thanks
Ravi.T