// a.cc
#include "a.h"
// a.h
#include "b.h"
#include "c.h"
// b.h
#include "c.h"
// c.h
#include <string>
"b.h" is being processed directly by current compliation unit
"c.h" is being processed indirectly by "gcc -H"
I want to prevents developers from including "c.h" directly in "a.cc".A way to specify some metadata rules by cmake/gcc, like bazel
gcc has plugin event "PLUGIN_INCLUDE_FILE", Unfortunately, the information provided, unlike clang, is not sufficient to do this, (maybe I didn't find it)
P.S. I want to do something like bazel layercheck(https://bazel.build/reference/be/c-cpp#hdrs )(clang -fmodules-decluse blabla...), using cmake and gcc toolchain
P.S. "xx.h" and "xx.cc" is component unit if the same base name
Command line option
-Hcauses gcc print the name of each header file included.Automatically generated
.dheader dependency files also contain full paths of all files included for a.ofile.You can use the same method gcc uses for this purpose. E.g. /usr/lib/gcc/x86_64-linux-gnu/11/include/avx2intrin.h: