Main Page
From Cppsyntax
NOTE: I was having real trouble with wiki spam, so I deleted a bunch of users and pages wholesale. If you or a page got deleted, please accept my apologies! If you have trouble logging in again, please let me know -- ducky at webfoot period com.
This wiki is for explaining errors that come up when working with C++. This page has a list of syntax errors. On the page for each syntax error, there are examples of how you can get the error. Note that the list of examples is not exhaustive! There might be other ways of getting the error.
If you came here looking for an explanation of a syntax error, and you couldn't find what you were looking for, please come back and add it when you have figured it out.
See the Community Portal for information about how you can contribute, about the project, and about our community.
This wiki was started on 1 July 2007, and will probably take a while to get going. That's okay. For the near term, it will be weighted heavily towards syntax errors that g++ gives. If you are a whiz with other compilers, please help out!
NOTE! I haven't double-checked these yet, so there might be typos.
Contents |
[edit] Syntax Errors
- no matching function for call to ‘Foo::Foo()’
- ‘Foo’ was not declared in this scope (class)
- similar to ‘Foo’ does not name a type
- ‘bar’ was not declared in this scope (instance)
- conversion from ‘Foo*’ to non-scalar type ‘Foo’ requested
- expected unqualified-id before ‘:’ token
- request for member ‘bar’ in ‘aFoo’, which is of non-class type ‘Foo*’
- undefined reference to Foo::bar()
- new types may not be defined in a return type
- request for member ‘pixelWidth’ in ‘this’, which is of non-class type ‘Tile* const’
- base operand of ‘->’ has non-pointer type ‘Foo’
- invalid operands of type ‘int’ and ‘const char [3]’ to binary ‘operator<<’
- ‘cout’ was not declared in this scope
- invalid in-class initialization of static data member of non-integral type ‘const char*’
- ‘int Foo::bar()’ cannot be overloaded
- cannot declare member function ‘static int Foo::bar()’ to have static linkage
- 'for' loop initial declaration used outside C99 mode
- jump to case label crosses initialization of 'Foo foo'
Parsing errors:
- expected constructor, destructor, or type conversion before ‘namespace’
- expected initializer before numeric constant
- expected initializer before ‘x’
- expected primary-expression before ‘=’ token
- expected unqualified-id before ‘)’ token
- expected identifier before ‘&’ token
- expected `)' before ‘aFoo’
- expected ‘;’ before ‘}’ token
- expected `;' before numeric constant
- expected `;' before string constant
- expected `:' before ‘int’
- expected `:' before ‘static’
- expected initializer before ‘Foo’
- expected class-name before ‘{’ token
Inclusion errors:
[edit] Warnings
- extra tokens at end of #include directive
- no newline at end of file
- Warning: size of symbol `Foo::bar()' changed from 102 in ./Foo.o to 104 in Baz.o
- warning: comparison between signed and unsigned integer expressions
[edit] Other sources of information on C++ syntax errors
- http://people.engr.ncsu.edu/efg/210/s99/Notes/errors.html
- http://ugweb.cs.ualberta.ca/~rod/tutorials/error_messagesC.html
- http://www.storkyak.com/2006/07/gnu-c-error-messages-explained.html and http://www.storkyak.com/2006/07/more-gnu-c-error-messages-explained.html
- http://www.andrewdavidson.com/articles/crypticvisualc/ (Visual C++)
- http://www.comp.leeds.ac.uk/hannah/cpp/errors.html
- http://www.csee.umbc.edu/courses/undergraduate/341/misc/CommonErrors.shtml
