Sometimes, beeing a GNU compiler manufacturer is difficult! People blame you for stuff that actually is implemented correctly. A popular mistake involves multiple pointer declarations!
char a;
char b;
char c;
The statement above can be merged into a single instruction easily:
char a, b, c;
Now take a look at this:
char* a;
char* b;
char* c;
Simplifying this with common sense leads to:
char* a, b, c;
But be careful-this does not do what you want it to. The star operator ties to the variable name and not to the type. So, you would end up with a char pointer a and two char variables b and c.
The correct way of simplification looks like this:
char *a, *b, *c;
This mistake happens often. It gets even more complicated when macros/typedefs are involved. Thus, if you ever see multiple pointers defined in a single instruction-be careful!
Did you ever have such a problem?
Related posts:







Havent done enough programming to make that mistake, but it looks like something I might do in CS class.
This is the normal behaviour of C, not GCC bug! It’s different from C#…
This isn’t really a big issue in my opinion, most compilers will most like catch the message when you try to either assign a pointer to or try to dereference the char.
Hi,
thats just what I said-it is C behaviour like it should be.
Just wanted to highlight this to show the trap to people who may fall into it(like me)!
Best regards
Tam Hanna