Skip to content
Latchkey

clang "error: no member named X in namespace std" in CI

A name like std::string or std::make_unique lives in a specific header and standard. If that header is missing, or the dialect is too old, clang reports "no member named X in namespace std".

What this error means

Code that built elsewhere fails on clang because a standard facility is used without its header, or because the C++ standard on the runner is older than the feature requires.

clang
app.cpp:6:8: error: no member named 'make_unique' in namespace 'std'
    6 |   auto p = std::make_unique<int>(3);
      |            ~~~~~^

Common causes

How to fix it

Include the declaring header

  1. Add the standard header that declares the name.
  2. Recompile to confirm std::X resolves.
C++
#include <memory>   // std::make_unique, std::unique_ptr

Select a recent C++ standard

Set the language standard high enough for the feature, both at the compiler and in CMake.

CMakeLists.txt
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

How to prevent it

  • Include the exact standard headers your code uses and pin a C++ standard high enough for the features, instead of depending on transitive includes.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →