I don't know of a portable representation of a byte other than a char.
 And while no one promises that a char is really a byte, I expect that
too much code would break and so it would be many many years before
this is changed in practice.

Likewise, no one promises that sizeof(int) == 4, but vendors haven't
changed this to 8 on 64 bit platforms either, opting instead to use
"long long" or "long int".

AFAIK there's nothing wrong with using void *, and most of the C
runtime functions like malloc use this.  C++, however, explicitly
disallows pointer arithmetic on a void *, so if you're programming in
C++, you may end up casting to a char * anyway.

On GNU/Linux I might include /usr/include/stdint.h, which typedefs
char to "int8_t" but, once again, AFAIK, there's no guarantee that
stdint.h is going to exist on every platform.

Wilson

On 12/8/05, Allan Wind <[EMAIL PROTECTED]> wrote:
> On 2005-12-08T10:37:36-0800, Wilson Yeung wrote:
> > You're expected to cast your structure into an unsigned char *,
> > because in C/C++, the only portable way to represent a byte is with a
> > char/unsigned char.
>
> Off-topic, I suppose, but what is a portable representation of a byte?
> What does unsigned char pointer give you that a void pointer does not
> (other than support for legacy compilers)?
>
>
> /Allan
>

Reply via email to