[cfe-dev] Warning when running syntax check on C++ header file

Jacob Carlborg via cfe-dev cfe-dev at lists.llvm.org
Sat Nov 25 07:36:03 PST 2017


I'm trying to run a syntax check on a C++ header file with .h extension 
and get a warning:

$ cat foo.h
class Foo {};
$ clang++ -fsyntax-only foo.h
clang-5.0: warning: treating 'c-header' input as 'c++-header' when in 
C++ mode, this behavior is deprecated [-Wdeprecated]
$ clang++ --version
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-apple-darwin17.2.0
Thread model: posix

Why is this, shouldn't Clang assume it's a C++ header since I invoked 
the compiler using "clang++"?

If I add "-x c++" I don't get the warning.

I'm no C++ expert but most C++ libraries I've seen are using .h as the 
extension for the header files.

-- 
/Jacob Carlborg



More information about the cfe-dev mailing list