| GNU C++ Compiler
|
Debugging: Compiler Errors
|
- compilation of header file requested
- You can't compile a header file--at least not with the
.h extension! If you really want to compile this,
either write a test program that includes your
library or temporarily rename your library .cpp (but
don't forget to change the name back when you're done).
- no such file or directory
- Check your spelling! Also, don't forget that if this is
a standard library (part of the C++ standard), you type
#include <library.h>, but if this is
a library you wrote, #include "library.h".
If it's a library I've made available to you, make sure
you include the full name to my directory:
#include "/homes/csg/1995/ordonez/cosc161/library.h"
- no match for `operator <<(...) / >>(...)'
- You're trying to
cout/cin something that
isn't a standard type (you may have placed a function
name where you really meant to have a function call).
- parse error before `?'
- This is the compiler's "general-purpose" error. Check the
following:
- semicolons at the end of:
- the previous line of code--if it's the end of a
statement, it should have a semicolon,
otherwise it shouldn't!
- function headers in definitions--often cause this
problem (remember, the prototype needs a
semicolon, the definition can't have one).
Rule of thumb: if it has a block (enclosed in
braces) after it, it shouldn't have a semicolon!
cout statements that continue on the
next line.
- braces and parentheses--match them up or this error will
show up all over the place!
cin/cout--make sure there are "arrows"
(<< or >>) between every 2 items
- spelling--especially keywords!
- type specifier omitted for parameter
- In a function prototype or definition, every parameter (or
argument) must have a type before it (you can't have a
function prototype like this:
int sum(int x, y);
even if they're both integers. You must enter
int sum(int x, int y);!
- syntax error before `?')
- This is often the result of leaving out the empty parentheses
after the name of a function that doesn't take parameters.
Remember that
void main, for example, always
needs the empty parentheses after it, even if it doesn't
take arguments. It's the compiler's way of keeping
function names and variable names separate.
- undeclared (first use this function)
- Make sure you've declared all your variables (at the top of
the function. Also check that you've spelled all names
the same way everywhere--both the declaration and every
use of a variable (remember that case matters).
If this error shows up in reference to a "language-standard"
object such as cout, cin, endl, etc., make
sure you're including all the right libraries!
- undefined or invalid # directive
- Check
#include, #define, etc. for misspellings.
- unterminated string or character constant / possible
real start of unterminated constant
- You forgot to close the double quotes at the end of a
string. It may even start on a different line than
where the error shows up.
- wrong type argument to unary minus
- You can't use dashes (minus signs) in names (function names
or variable names). Check also for a misplaced dash
elsewhere (just outside a string, etc.)!
Mail me your suggestions!
Back to Debugging Page
Back to GNU C++ Home Page
Back to my Home Page
Andrews University's Home Page