Common Compiler Errors and Quick Fixes

    Errors are in bold; description of the error follows the error.
 
 

unexpected end of file while searching for precompiled header directive

This error requires that you include the stdafx.h library as the first library you include:

#include "stdafx.h"

Cannot open include file: 'stdafx.h': No such file or directory Error executing cl.exe.

The way in which you have set up your workspace when creating a new project does not require the #include "stdafx.h", therefore delete this line (or comment it out).
 

unexpected end of file found

This is a 'somewhat' common error. In this case the end of file was reached unexpectedly. This means that the compiler was expecting a end '}'. Therefore you should verify that all begins '{' have their associated ends.

undeclared identifier (typically the specific identifier will be reported)

This error is common and may occur for a few reasons: 1) You misspelled the name of the variable. Remember that the C++ compiler is case sensitive (lower and/or upper case is important). 2) The specified identifier was not declared.

syntax error : missing ';' before 'int'

This is one of the clearest errors you can receive from the compiler (believe it or not). This says you are missing a semi-colon at the end of a declaration. int count=1 int wc; Clearly we need to add a semi-colon after the '1'.
 
 

MORE ADVANCED ERRORS


error C2440: '=' : cannot convert from 'const char' to 'char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast

This is a compiler error dealing with a character array. What was expected is unknown[i] ='*'; however what was coded: unknown = '*'; When referring to a specfic cell you must specify the index.

You may receive a similar error when passing arrays to functions.  When passing arrays or matrices to functions you do not specify the size.  For example,

void f(int localArray[10]) { .. }

int main() {
  int A[10];

  f(A);
}


Chris Alvin

Last modified: Fri Oct 27 01:43:44 CDT 2000