CppPilot

C++ / Documentation search

Find the error. Find the next step.

Search by diagnostic code, copied message, or symptom. Filter by content and project system.

  1. Examples and diagramsMSBuild + CMake

    C2280: A lambda that owns one is stored in std::function .

    std::function requires a copyable callable: use std::move_only_function in C++23, or a std::shared_ptr .

  2. Examples and diagramsMSBuild + CMake

    C2280: A member makes assignment impossible.

    A const or reference member deletes the copy assignment: assign member by member, or store a pointer.

  3. Examples and diagramsMSBuild + CMake

    C2280: A non-copyable object is copied.

    std::unique_ptr , std::thread , and std::mutex cannot be copied: pass them by reference, or transfer movable types with std::move . A std::mutex cannot be moved either; share it by reference.

  4. Examples and diagramsMSBuild + CMake

    C2440: A void* becomes a typed pointer.

    C++ needs an explicit static_cast<T*> , for example on the result of malloc .

  5. Examples and diagramsMSBuild + CMake

    C2440: A pointer to const data is assigned to a pointer to mutable data.

    Preserve the pointed-to type's const , rather than casting const away.

  6. Examples and diagramsMSBuild + CMake

    C2440: A string literal is assigned to char* .

    String literals are constant. Since conformance mode ( /permissive- ) is on in new projects, write const char* or use std::string .

  7. Examples and diagramsMSBuild + CMake

    C2440: An enum class is used as an integer.

    Scoped enumerations do not convert implicitly: use static_cast<int> .

  8. Examples and diagramsMSBuild + CMake

    C2440: The types are unrelated.

    No cast makes unrelated types compatible safely: check that you use the variable you meant.

  9. Examples and diagramsMSBuild + CMake

    C2512: A container creates elements without arguments.

    std::map::operator[] , vector::resize , and arrays need a default constructor: use map.at , try_emplace , or emplace_back instead.

  10. Examples and diagramsMSBuild + CMake

    C2512: A member or a base class has no default constructor.

    Initialize it in the member initializer list of every constructor: Line() : start(0, 0), end(0, 0) {} .

  11. Examples and diagramsMSBuild + CMake

    C2512: The class declares only constructors with parameters.

    Pass the arguments, or add a default constructor: Point() = default; with default member values.

  12. Examples and diagramsMSBuild + CMake

    C2664: A const object is passed to a non-const parameter.

    Make the parameter const , or pass a copy.

  13. Examples and diagramsMSBuild + CMake

    C2664: A narrow string is passed to a Unicode Windows function.

    With Character Set set to Unicode, MessageBox is MessageBoxW and expects wide strings: write L"Hello" , call MessageBoxA , or use TEXT("Hello") .

  14. Examples and diagramsMSBuild + CMake

    C2664: A temporary is passed to a non-const reference.

    A parameter std::string& does not accept a literal or a temporary: take const std::string& when the function does not change it.

  15. Examples and diagramsMSBuild + CMake

    C2664: The arguments are in the wrong order.

    Compare the call with the declaration the message shows; another overload may be the one you meant.

  16. Examples and diagramsMSBuild + CMake

    C3861: The function is defined below the call.

    Declare it before the call ( int Compute(int); ), in a header or at the top of the file, or move its definition above.

  17. Examples and diagramsMSBuild + CMake

    C3861: The function is in a namespace.

    Qualify it, for example std::sort or utils::Compute .

  18. Examples and diagramsMSBuild + CMake

    C3861: The function is inside #ifdef .

    Its declaration may be excluded for this configuration or platform: check the preprocessor definitions of the configuration you build.

  19. Examples and diagramsMSBuild + CMake

    C3861: The header that declares it is not included.

    Include it: std::max needs <algorithm> , printf needs <cstdio> .

  20. Examples and diagramsMSBuild + CMake

    C4244: Arithmetic on small types is assigned back.

    char and short are promoted to int in expressions: cast the result when you store it in the smaller type.