M
Mark Adler
Helpful C swamis,
In the good old days, any self-respecting C compiler knew what you
meant when you did arithmetic on a void * pointer, i.e. that the units
were bytes. Then someone decided that we would all be more productive
somehow if the compilers couldn't figure out obvious things like that
on their own. So now you can't do arithmetic on void * pointers.
Ok, fine. So I adjusted, I would do this:
void *buf;
int n;
(char *)buf += n;
But now I'm getting nastygrams like "warning: target of assignment not
really an lvalue; this will be a hard error in the future". Once again
someone, probably the same person, decided that compilers shouldn't
have to burden this great responsibility of understanding obvious
things like that. (And why a cast of a pointer to another pointer type
is no longer a pointer, I have no idea.)
So now what am I supposed to do? It starts to get just downright silly. E.g.
void *buf;
int n;
char *cmon;
cmon = (char *)buf;
cmon += n;
buf = (void *)cmon;
Is there a better way to work around this, at least until the *next*
dumbing down of the language?
Mark
In the good old days, any self-respecting C compiler knew what you
meant when you did arithmetic on a void * pointer, i.e. that the units
were bytes. Then someone decided that we would all be more productive
somehow if the compilers couldn't figure out obvious things like that
on their own. So now you can't do arithmetic on void * pointers.
Ok, fine. So I adjusted, I would do this:
void *buf;
int n;
(char *)buf += n;
But now I'm getting nastygrams like "warning: target of assignment not
really an lvalue; this will be a hard error in the future". Once again
someone, probably the same person, decided that compilers shouldn't
have to burden this great responsibility of understanding obvious
things like that. (And why a cast of a pointer to another pointer type
is no longer a pointer, I have no idea.)
So now what am I supposed to do? It starts to get just downright silly. E.g.
void *buf;
int n;
char *cmon;
cmon = (char *)buf;
cmon += n;
buf = (void *)cmon;
Is there a better way to work around this, at least until the *next*
dumbing down of the language?
Mark