|
From: | Dave Hansen |
Subject: | Re: [avr-gcc-list] Support for ATMega256 and ATMega2560 |
Date: | Fri, 14 May 2004 16:29:11 -0400 |
From: Joerg Wunsch <address@hidden>
[...]
The C language (at least starting with `ANSI' C, the old K&R has been notorously lax about this) strictly distinguishes pointers of different types, i. e. a char * is fundamentally incompatible with an int * from the language standard's point of view. Converting one pointer to another one is beyond the guarantees of the standard. The only conversion covered by the standard is that you can convert any explicitly typed pointer into a void *, and back from that void * into its original type elsewhere (but not into a different one), so it is guaranteed the resulting pointer will point again to the same object.
This is correct except for pointers to functions. There is no guarantee that a pointer to function can be converted to a pointer to void and back again. However, the _is_ a guarantee that a pointer to a function of one type can be converted to a pointer to a function of any other type and back again. So a (void (*)(void)) can serve as a generic pointer to function.
Also, a pointer to void is guaranteed to have the same alignment and representation as a pointer to unsigned char.
I figure you know this, just clarifying in case some else doesn't. Regards, -=Dave _________________________________________________________________Watch LIVE baseball games on your computer with MLB.TV, included with MSN Premium! http://join.msn.click-url.com/go/onm00200439ave/direct/01/
[Prev in Thread] | Current Thread | [Next in Thread] |