C++ guides
Modern C++ guides: C++20 and C++23 features, compilers, build systems, and measured performance.
-
Invalid Use of Incomplete Type Fix Error Reference
GCC stops the build with 'invalid use of incomplete type' when code uses a forward-declared class as if its definition were known: calling a member...
-
DSO Missing From Command Line Fix Error Reference
A program that calls a function from a shared library B directly, but names only library A on the link line, fails even though A itself depends on B: the...
-
Double Free Detected in Tcache Fix Error Reference
Deleting the same allocation twice is undefined behavior, and glibc's allocator catches the common case: the second delete reaches free() with the chunk...
-
Cannot Declare Variable of Abstract Type Fix Error Reference
GCC stops the build when code tries to create an object of a class that still has a pure virtual function with no final overrider: 'cannot declare...
-
Was Not Declared in This Scope Fix Error Reference
This error means the compiler reached a name and found no declaration for it in the scope where it is used: a misspelled name, a name used before its...
-
C++ Invalid Types Array Subscript Fix Error Reference
This error means the value before the brackets is a single value, not an array, a pointer, or a type with its own subscript operator: an int, a double, a...
-
C++ Return Value in Void Fix Error Reference
This error means the function was declared void but its return statement carries a value: a literal, an arithmetic expression, a local variable, the result...
-
C++ No Member Named Fix Error Reference
This error means the name after a dot is not a member of the object's class: a misspelled member name, a member that belongs to a different standard...
-
C++ Invalid Type Argument Unary * Fix Error Reference
This error means the value after the star is not a pointer: an int, a double, a char, a bool, a null pointer value, or an int returned by a function. This...
-
C++ Invalid Operands Binary Operator Fix Error Reference
This error means a built-in binary operator was given a pair of operand types it does not accept: two pointers added together, two string literals added...
-
C++ Invalid Conversion Void* Fix Error Reference
This error means a void* value was used where an int* is required, and C++ provides no implicit conversion in that direction: a void* variable initializing...
-
C++ Extra Qualification Fix Error Reference
This error means a member inside its own class definition was written with the class name in front of it: Foo::bar, Foo::count, Foo::Foo, a qualified static...
-
C++ Expected Unqualified-Id Fix Error Reference
This error means the compiler reached a place where a name had to appear and found something that cannot be a name instead: a keyword used as a variable or...
-
C++ Else Without Previous If Fix Error Reference
This error means an else appears where no unmatched if is waiting for it: an else with no if at all, an else after a plain braced block, an else separated...
-
C++ Read-Only Assignment Fix Error Reference
This error means the variable on the left of an assignment was declared const: a const local reassigned later, a const auto variable updated in a loop, a...
-
C++ Undefined Reference to Main Fix Error Reference
The linker, not the compiler, reports a missing main: no main at all, main inside a namespace, a capitalised Main, a main that is declared but never...
-
C++ Undefined Reference to Function Fix Error Reference
Every file compiles and the link still fails with undefined reference to one ordinary function: its definition sits in a file left out of the link command...
-
C++ Redefinition Error Fix Error Reference
A second definition in one C++ file is rejected, but GCC does not use one wording for it: a local variable is a redeclaration, a global variable, a...
-
C++ Narrowing Conversion Error Fix Error Reference
Braces turn silent truncation into a compile error: a double in an int's braces, a constant too wide for a char, a negative value in an unsigned...
-
C++ Lvalue Required Assignment Fix Error Reference
This error means the left side of an assignment names a value, not a place to store one: a literal, the result of a function that returns by value, a...
-
C++ Header Not Found Fix Error Reference
The preprocessor stops at an #include line with a fatal error - the named header file is not found: the name is misspelled, a project header sits in a...
-
C++ Expected Semicolon Error Fix Error Reference
A missing semicolon is reported at the token that follows it, not on the line that lacks it: after a variable declaration the error names the next...
-
C++ Expected Primary-Expression Fix Error Reference
This error means an operator or bracket was left waiting for a value that never arrives: a missing operand after a binary operator, a trailing comma in a...
-
C++ Does Not Name a Type Fix Error Reference
A name sits where a type is required and the compiler answers that it does not name a type: the header that declares it was never included, the name is...
-
C++ Break Outside Loop Fix Error Reference
This error means a break stands where no loop or switch encloses it: inside an if with no loop anywhere, inside a helper function called from a loop, inside...
-
Fix C++ "request for member in pointer type" — Use -> on Pointers, and Why -> Cannot Fix a Non-Class Type Error Reference
The GCC error request for member in a pointer type means the dot operator was used on a pointer: dot requires an object of class type, arrow requires a...
-
Fix C++ "no match for 'operator<<'" — Streaming a User-Defined Type and a std::vector of It to std::cout Error Reference
Streaming a user-defined type to std::cout fails with no match for 'operator<<' because std::basic_ostream provides overloads only for...
-
Fix C++ "invalid conversion from 'const char*' to 'char*'" — Add const, Copy the Text, or Own It in std::string Error Reference
The GCC error invalid conversion from 'const char*' to 'char*' means read-only text was handed to code that claims the right to modify...
-
Fix C++ "'cout' was not declared in this scope" — Missing
, Missing std::, and the using namespace std Trade-Off Error ReferenceThe error 'cout' was not declared in this scope has two different causes with the same first line: no
included at all, or... -
Fix C++ "cannot convert 'std::string' to 'const char*'" — c_str(), data(), and When the API Wants char* Error Reference
Passing a std::string where a const char* is expected fails because there is no implicit conversion from std::string to a character pointer. This guide...