Girish Mahajan (Editor)

Compilation error

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

Compilation error refers to a state when a compiler fails to compile a piece of computer program source code, either due to errors in the code, or, more unusually, due to errors in the compiler itself. A compilation error message often helps programmers debugging the source code for possible errors.

Contents

Common C++ compilation errors

  • Undeclared identifier, e.g.:
  • doy.cpp: In function `int main()': doy.cpp:25: `DayOfYear' undeclared (first use this function)

    This means that the variable "DayOfYear" is trying to be used before being declared.

  • Common function undeclared, e.g.:
  • xyz.cpp: In function `int main()': xyz.cpp:6: `cout' undeclared (first use this function)

    This means that the programmer most likely forgot to include iostream.

  • Parse error, e.g.:
  • somefile.cpp:24: parse error before `something'

    This could mean that a semi-colon is missing at the end of the previous statement.

    Internal Compiler Errors

    An internal compiler error (commonly abbreviated as ICE) is an error that occurs not due to erroneous source code but rather due to a bug in the compiler itself. They can sometimes be worked around by making small, insignificant changes to the source code around the line indicated by the error (if such an line is indicated at all), but sometimes larger changes must be made such as refactoring the code to avoid certain constructs or using a different compiler or different version of the compiler.

    Example of an internal compiler error:

    somefile.c:1001: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugs.gentoo.org/> for instructions.

    References

    Compilation error Wikipedia