variable declaration

R

Rahul

Hi Everyone,

I had the following declaration and i expected the compiler to give
an error, but it didn't, how does it interpret the declaration?

const * int ptr;

Thanks in advance!!!
 
J

Jeff Schwab

Juha said:
result = a * int (b);

What compiler does that? GCC 4.2 rejects both of these:

int main() { const * int ptr; }
int main() { void* ptr = 0; const * int ptr; }

Both cases cause the same diagnostic:

g++ -ansi -pedantic -Wall main.cc -o main
main.cc: In function 'int main()':
main.cc:1: error: expected unqualified-id before 'int'
main.cc:1: error: expected initializer before 'int'
 
J

Jeff Schwab

Jeff said:
What compiler does that? GCC 4.2 rejects both of these:

int main() { const * int ptr; }
int main() { void* ptr = 0; const * int ptr; }

Both cases cause the same diagnostic:

g++ -ansi -pedantic -Wall main.cc -o main
main.cc: In function 'int main()':
main.cc:1: error: expected unqualified-id before 'int'
main.cc:1: error: expected initializer before 'int'

I should have mentioned that trying to assign "a * int b" produces a
similar diagnostic: "expected primary-expression before 'int'".
 
T

terminator

I should have mentioned that trying to assign "a * int b" produces a
similar diagnostic: "expected primary-expression before 'int'".

you`ve missed the braces around 'b'.

regards,
FM.
 
J

Jeff Schwab

terminator said:
you`ve missed the braces around 'b'.

Yes, I know. That's the point.

Juha snipped the part that would have made that clear, and I did not put
it back. Please see the original post in this thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,886
Members
47,419
Latest member
ArturoBres

Latest Threads

Top