Thread overview | |||||
---|---|---|---|---|---|
|
April 23, 2004 is it realy possible without preprocessor? | ||||
---|---|---|---|---|
| ||||
imagine this case: #define entry(myappclass) int main(int argc,char **argv){app=new myappclass;return my_main(argc,argv);} i'm doing a class library and i don't want user to make main function it seems to me it is impossible without a #define templates need to be created somewhre (main) alises work only for data types and it is not good to do it in the constructor of [myappclass] because all global objects need to be constructed first... |
April 23, 2004 Re: is it realy possible without preprocessor? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | There are lots of thing that cannot be done without preprocessor. The question is, whether they really *need* to be done. Why make a hassle over three lines that users have to write? Anyone using D expects to write a main routine anyway.
bobef wrote:
> imagine this case:
>
> #define entry(myappclass) int main(int argc,char **argv){app=new
> myappclass;return my_main(argc,argv);}
>
> i'm doing a class library and i don't want user to make main function it seems to me it is impossible without a #define
>
> templates need to be created somewhre (main)
> alises work only for data types
> and it is not good to do it in the constructor of [myappclass]
> because all global objects need to be constructed first...
|
April 23, 2004 Re: is it realy possible without preprocessor? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | In article <c6buno$1tae$1@digitaldaemon.com>, bobef says... > >imagine this case: > >#define entry(myappclass) int main(int argc,char **argv){app=new >myappclass;return my_main(argc,argv);} > >i'm doing a class library and i don't want user to make main function it seems to me it is impossible without a #define > >templates need to be created somewhre (main) >alises work only for data types >and it is not good to do it in the constructor of [myappclass] >because all global objects need to be constructed first... > > Have the user write this: static this() { entry!(SomeClass)(); } And define somewhere else: template entry (T) { void entry() { app=new T; } } int main(char [][] args) { return my_main(args); } Although I bet that main could be replaced by whatever my_main does. BTW, I didn't test the code. ------------------- Carlos Santander B. |
Copyright © 1999-2021 by the D Language Foundation