How to fix error: unknown type name ‘namespace’
Had this issue with YCM and clang. Turns out, the missing flag was "-x", "c++"
.
From the official clang documentation:
-x <language> : Treat subsequent input files as having type language.
It sounds like you're trying to compile your C++ code with a C compiler. Try using g++
instead of gcc
and giving your file a C++ extension such as .cpp
(rather than .c
).
I had a similar issue and found this question but the solutions don't match mine completely, so I'm adding mine here.
In my case, I was including a header file in .cpp files and .c files. The solution was to split off the namespace part of the header since that was obviously only needed in the .cpp files.