在 C++ 模式下将 'c-header' 输入视为 'c++-header',此行为已弃用

Treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated

这类似于Warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated。但是,OP 试图编译头文件。就我而言,我正在尝试生成依赖项:

$ git diff
diff --git a/GNUmakefile b/GNUmakefile
index 791ef05..ce48a59 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -175,6 +176,11 @@ LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
 TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
 DLLTESTOBJS = dlltest.dllonly.o

+-include GNUmakefile.deps
+
+GNUmakefile.deps:
+       $(CXX) $(CXXFLAGS) -MM *.h *.cpp > GNUmakefile.deps
+

如何使用 CXX 构建依赖项同时避免 Clang 警告?

c++ 编译器的-MM 选项将给出输入文件的所有依赖项列表。假设您实际编译 .cpp 文件(并且不执行 $(CXX) -c xyz.h 或类似的操作),则仅 .cpp 文件需要依赖项。所以将其更改为:

 $(CXX) $(CXXFLAGS) -MM *.cpp > GNUmakefile.deps

应该在 GNUmakefile.deps.

中提供您需要的所有依赖项