advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Average Rating: 1.3/5 | Rate this item | 4 users have rated this item.
Expertise: Beginner
Language: C++
August 14, 2009
Decoding General Compiler Error Messages

Error: Undeclared Identifier

Example error message:

doy.cpp: In function 'int main()': doy.cpp:25: 'DayOfYear' undeclared
(first use this function) doy.cpp:25: (Each undeclared identifier is reported only
once for each function it appears in.) doy.cpp:25: parse error before ';' token

Meaning:

You used DayOfYear in your code, but the compiler has not seen a definition for DayOfYear. It doesn't know what DayOfYear is.

Usual Causes

  1. You forgot to include the header file that defines the class/struct/function/etc.
  2. You misspelled the name of the identifier.

Error: cout Undeclared

Example error message:

xyz.cpp: In function 'int main()': xyz.cpp:6: 'cout' undeclared (first use
this function) xyz.cpp:6: (Each undeclared identifier is reported only once for each
function it appears in.)

Meaning

This is really a special case of the "Undeclared Identifier" error.

Usual Causes

  1. You forgot to include <ostream>.
  2. You forgot using namespace std;.
Kumar Arvind
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
Please rate this item (5=best)
 1  2  3  4  5
advertisement
advertisement