int const * p;
is allowed ?
GCC treats it as
const int * p;
SUN's acc gives an error.
//////\\
/ \
_| _ _ |_
|.|-(.)-(.)+.|
\| J |/
\ --- /
\ /
"####"
Joachim
Yes, it is legal. A compiler that rejects it is not Standard-conforming.
Yes, it would be very easy for you to look that up :-)
(Some parts of the standard are obscure, but not this one.)
>GCC treats it as const int * p;
That is correct.
>[Other compiler] gives an error.
If the vendor claims that that compiler is ANSI or ISO conforming, and if
you paid money for it, then get a refund. [Personal opinion only.]
--
Norman Diamond dia...@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
"Yeah -- bad wiring. That was probably it. Very bad."
I apologize to SUN, Jutta you're right. The fact is, in my test
program I jumped to the wrong line. So
int const * p;
is accepted by acc and gcc. The error message occured in the line
const int const *q;
which IMO is incorrect, or at least useless.
acc reports: "constp.c", line 4: invalid type combination
gcc reports: constp.c:4: warning: duplicate `const'
Thanks to all who answered
"Constraints
The same type qualifier shall not appear more than once in the same
specifier list or qualifier list, either directly or via one or more
typedefs."
Your opinion is fact, it is incorrect.
However Joachim, I believe your appearance, if not your const problems,
could be improved by parting your hair on the other side, switching to
contact lenses and smiling. You would then look like this:
//\\\\\\
/ \
_| _ _ |_
|.| o o | }
\| \ |/
\ \ / /
\ ~ /
"####"
Joachim V2.0
--
lin...@eng.sun.com|| P. van der Linden and his uncustomary theories.
Go Giants!! Don't || When solving a "panic" you must first ask yourself what you
stop at Florida...|| were doing that could possibly frighten an operating system
That construct isn't precluded;
const int * const a;
is OK. That declaration has two separate qualifier lists: one associated with
the type (int *) and one associated with the variable, essentially separated
by the *.
> const int * const a;
>is OK.
Yes, but it's terribly confusing.
For consistency, you should always put `const'
_after_ the type that it modifies. Just like `*'.
So the declaration should be:
int const * const a;
It's too bad that common usage has this backwards.
Even the standard's examples are backwards.