[FEA]: CCCL headers should ensure users do not see warnings caused by CCCL code #527
Closed
4 tasks done
Labels
cub
For all items related to CUB
feature request
New feature or request.
libcu++
For all items related to libcu++
thrust
For all items related to Thrust.
Is this a duplicate?
Area
General CCCL
Is your feature request related to a problem? Please describe.
As a user of CCCL, when I include a CCCL header like
#include <cub/cub.cuh>
and compile my program, I do not want to see warnings emitted from thecub.cuh
header. In addition to being annoying, I may compile with-werror
that turns all warnings into errors and such warnings would break my build.The normal solution to this problem is to use
-isystem
for the include search path:So including headers with
-isystem
will silence any warnings.However,
-isystem
does not work when compiling withnvcc
with any headers that are shipped in the CTK.This is because
nvcc
implicitly includes the CTK include dir as-I
. This can be seen by inspecting the verbose output fromnvcc -v
.yields
-I
paths are searched beforeisystem
paths, so the headers from the CTK will always be found first.Luckily there is another solution:
gcc, clang, and msvc all support some form of this same directive:
#pragma GCC system_header
#pragma clang system_header
#pragma system_header
Note, using this
#pragma
in a header will not leak to the file that included it. It applies only to the file in which the pragma resides.Therefore, if we add these pragmas to the beginning of every CCCL header, then it will automatically silence warnings from our headers.
Describe the solution you'd like
We should define a new macro like (naming is just for illustration and can be changed):
And use this at the top of every CCCL header file. It must be used directly in each file since it does not impact any files other than the one in which it is used.
It should be opt-out with
CCCL_DISABLE_IMPLICIT_SYSTEM_HEADER
so we can still have warnings enabled when we compile our own tests.libcudacxx
headers already use#pragma GCC system_header
directly:cccl/libcudacxx/include/cuda/std/detail/libcxx/include/latch
Line 54 in 265b574
So we should update this, and add it to Thrust and CUB headers as well.
Tasks
Describe alternatives you've considered
No response
Additional context
It's likely we'll have other scenarios where we want to insert stuff at the top of every CCCL header file. Therefore, we could also consider adding a higher-level macro like:
Additionally, I thought an easy way we could sneak in the
CCCL_IMPLICIT_SYSTEM_HEADER
macro without having to manually touch every file would be to just prepend it to our namespace macros like so:but that expands out to:
which fails to compile. I don't think there's a way to generate a new line as part of a macro expansion.
The text was updated successfully, but these errors were encountered: