Re: [AD] got rid of END_OF_MAIN()

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Michael Benfield wrote:
If you mean from quite a while before, then ok.

I'm not actually sure what the concensus was, but I was told by Bobn on Allegro.cc that doing something like:
#define main \
_mangled_main(int, char **); \
int main(int argc, char **argv) \
{ \
   return _mangled_main(argc, argv); \
} \
int _mangled_main

was not something they wanted to do. And with good reason.

I don't understand this. There's no need to make everything that's valid C be valid for Allegro. I mean, currently this:

int main(int argc, char *argv[])
{ whatever.... }

(without the END_OF_MAIN) is valid C but it doesn't work with Allegro.

Yes it does.. for systems that don't require any special processing, anyway.


Unless you know something I don't this is irrelevant. Allegro already does
#define main _mangled_main
So how is my way any different?

Because that'll soimply rename things called main to _mangled_main. Whereas a patch like the one I wrote above would insert arbitrary code and confuse the compiler. For example:

struct blah {
   int main;
};

would currently simply change to:

struct blah {
   int _mangled_main;
};

but with a patch like mine would become:

struct blah {
   int _mangled_main(int, char **);
   int main(int argc, char **argv)
   {
      return _mangled_main(argc, argv);
   }
   int _mangled_main;
};

Besides being invalid C, it introduces a main() method to the struct, as well as causes _mangled_main to have two different declarations.

- Kitty Cat




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/