How to include C11 headers when compiling C++ with GCC?

Viewed 6184

In a C++ project, I'm using a C library which includes some C11 headers. It won't compile with GCC. See this simple code:

// main.cc
#include <stdatomic.h>

int main()
{
    return 0;
}

Running gcc main.cc -lstdc++, it complains: error: ‘_Atomic’ does not name a type. However, clang main.cc -lstdc++ works like a charm. I'm wondering what makes the difference, and how can I compile it with gcc?

1 Answers
Related