Currently when I compile this code in Visual C++ 10:
Undeclared var;
the compiler emits the following error messages:
error C2065: 'CUndeclared' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'var'
error C2065: 'var' : undeclared identifier
where only the first one is helpful and the rest only increase noise in the output. Now I understand that perhaps producing prettier looking error messages was not the top priority in compiler development.
What I want to know is - is it possible at all to have better error reporting in C++ or is C++ so hardcore that the compiler had no choice but to report three errors here?
is it possible at all to have better error reporting in C++ or is C++ so hardcore that the compiler had no choice but to report three errors here?
up to a certain extent, yes (see clang output from James' answer). it's the compiler's error recovery techniques that decides how it would report errors. (a little older) gcc or msvc seems not to care about error recovery and instead keep on parsing the rest of the source code, causing subsequent errors to be noise instead of true errors. clang is much better in this case. see this post.