-
Notifications
You must be signed in to change notification settings - Fork 218
C Coding Guidelines
Bernhard Manfred Gruber edited this page May 26, 2025
·
1 revision
- Always use entities from
cuda::std::
overstd::
. They work in host and device code and help testing our implementation. - Use CCCL internal macros over compiler/vendor-specific keywords. E.g., use
_CCCL_HOST_DEVICE
instead of__host__ __device_
. This excludes examples and documentation. - Fully qualify any reference to a libcu++ entity. Prefer
::cuda::std::
, or_CUDA_VSTD::
, over justcuda::std
. This avoids ambiguities when users define their namespaces calledcuda
. - Doxygen comments should start with
//!
- Macros for function attributes, like
_CCCL_HOST_DEVICE
, should be ordered before declaration specifiers likeconstexpr
orstatic
- Don't include libcu++ detail headers (starting with
__
) in downstream projects (like CUB, Thrust, etc.). Always prefer the public headers.
- Always use the corresponding namespace macro to refer to a libcu++ entity over qualifying with a libcu++ namespace. E.g., use
_CUDA_VSTD::enable_if
overcuda::std::enable_if
. - Always fully qualify function calls, even to functions in the same namespace.
- Defaulted constructors should be marked with
_CCCL_HIDE_FROM_ABI
- libcu++ headers like
<cuda/foo>
are strict supersets of<cuda/std/foo>
and thus always include the corresponding<cuda/std/...>
header.