Saturday, August 1, 2015
Cryptic Compiler Error Messages
I had a piece of code with obvious typo
int main
{
foo * p;
p = new bar();
p->f1();
return 1;
}
The compiler messages were cryptic
g++ -std=c++11 c10.cpp -o c10
c10.cpp:48:6: error: expected primary-expression before '*' token
foo * p;
^
c10.cpp:48:8: error: 'p' was not declared in this scope
foo * p;
^
c10.cpp:48:9: error: expected '}' before ';' token
foo * p;
^
c10.cpp:49:2: error: 'p' does not name a type
p = new bar();
^
c10.cpp:50:2: error: 'p' does not name a type
p->f1();
^
c10.cpp:52:2: error: expected unqualified-id before 'return'
return 1;
^
c10.cpp:53:1: error: expected declaration before '}' token
}
^
Can the compiler messages be made better ?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment