RE: [AD] fceil

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


> > Initializing a 'void *' pointer with the address of a function
> is a little
> > hazardous...
>
> I don't think so.  Putting a non-address in there would be bad for
> portability, but an address is an address is an address.
>
> Anyway, how do we get rid of the warnings without resorting to ugly
> typecasts?

I haven't been following this thread, so please forgive me if this is
irrelevant. However, this is one way of using a variable to store either a
function pointer or another type of pointer - or even another type of
variable. This should be totally portable.

typedef union {
   void (*proc)();
   char (*str)();
   int num;
} SPLAT;

SPLAT a;
enum {proc,str,num} t;

switch (t) {
   case proc: a.proc(); break;
   case str: textout(...,a.str(),...); break;
   case num: n=a.num;
}

Ben Davis



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