Re: [AD] fceil

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


> And the difference being...?  ;-)

Fairness with regard to MSVC on this particular topic ;-)

> 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.

Talking about portability, assigning a 'void *' pointer with the address of
a function is not really the best example...

> Anyway, how do we get rid of the warnings without resorting to ugly
> typecasts?

I know. The solution is traditionnally the one explained by Ben, but the
pointers to
function must have exactly the same signature to avoid typecasting.
But obviously this doesn't make the code simpler.

> 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;
>
> Uhm, I meant:
>
> char *str;

Yes. Maybe the discriminant has to be included in the type itsef:

#define CODE_PTR_ID 1
#define DATA_PTR_ID 2

typedef struct {
   union {
      void (*proc)(void);
      void *data;
   };
   int id;
} GENERIC_PTR;

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



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