|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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!!! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Rahul wrote:
> 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; You should probably ask the compiler or its developers. The '*' symbol cannot be followed by 'int'. Could be a bug in the compiler. V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Victor Bazarov wrote:
> The '*' symbol cannot be followed by 'int'. result = a * int (b); ![]() |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Juha Nieminen wrote:
> Victor Bazarov wrote: >> The '*' symbol cannot be followed by 'int'. > > 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' |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Juha Nieminen wrote:
> Victor Bazarov wrote: >> The '*' symbol cannot be followed by 'int'. > > result = a * int (b); > > ![]() I meant in a declaration. See subj. V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Jeff Schwab wrote:
> Juha Nieminen wrote: >> Victor Bazarov wrote: >>> The '*' symbol cannot be followed by 'int'. >> >> 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' I should have mentioned that trying to assign "a * int b" produces a similar diagnostic: "expected primary-expression before 'int'". |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Feb 22, 1:22am, Jeff Schwab <j...@schwabcenter.com> wrote:
> Jeff Schwab wrote: > > Juha Nieminen wrote: > >> Victor Bazarov wrote: > >>> The '*' symbol cannot be followed by 'int'. > > >> 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' > > 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. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
terminator wrote:
> On Feb 22, 1:22 am, Jeff Schwab <j...@schwabcenter.com> wrote: >> Jeff Schwab wrote: >>> Juha Nieminen wrote: >>>> Victor Bazarov wrote: >>>>> The '*' symbol cannot be followed by 'int'. >>>> 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' >> 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'. 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. |
|
![]() |
| Outils de la discussion | |
|
|