We have a C++ job that checks that all headers compile on their own, but of course, we should test this on C also…
The example binaries cover some headers, but not by all (e.g., there’s no example for ellswift or prealloc).
We have a C++ job that checks that all headers compile on their own, but of course, we should test this on C also…
The example binaries cover some headers, but not by all (e.g., there’s no example for ellswift or prealloc).
There is a common guideline, that for any header file, there should be an associated source file, which #include
s that header, even if the source file otherwise is empty.
This not only make sure that header files are self contained, but also static code analysis tools like clang-tidy or iwyu only report warnings from the current source file and the associated header. For those tools, an associated source file needs to exist, or diagnostics in headers are silently ignored.
For a file stem.h
, both stem.c
and stem_test.c
are considered associated source files. Since some compilers dislike source files that don’t provide any symbols, the easiest approach is to use stem_test.c
and actually put a test in it.
This issue is mean to cover the public headers.
This not only make sure that header files are self contained,
For self-contained public headers, see #1039.