Open bernhardmgruber opened 5 months ago
We discovered a further problematic example. Assume the following situation:
my_library.hpp
uses NVTX like:
#include <nvtx3/nvtx3.hpp>
...
nvtx3::scoped_range
But the user requests the explicit version:
#define NVTX3_CPP_REQUIRE_EXPLICIT_VERSION
#include <nvtx3/nvtx3.hpp>
#include <my_library.hpp>
int main() {
nvtx3::v1::scoped_range
}
This also fails compilation.
The problem basically is that we cannot have the explicit and non-explicit API of the same version in the same TU. What is your guidance to resolve this? Thx!
Hi, the documentation for
NVTX3_CPP_REQUIRE_EXPLICIT_VERSION
in thenvtx3.hpp
header containing the C++ API explains the following:However, this breaks user code using the unversioned API directly.
For example:
If
my_library.hpp
now changes fromto
the above user program breaks, because the unversioned API is no longer provided.
This happens in the second case because the first inclusion of
nvtx3.hpp
definesNVTX3_CPP_DEFINITIONS_V1_0
and emits the symbols into namespacenvtx3::v1
andv1
is not an inline namespace becauseNVTX3_CPP_REQUIRE_EXPLICIT_VERSION
is defined. The second inclusion will then see thatNVTX3_CPP_DEFINITIONS_V1_0
is already defined and not provide the unversioned API (e.g., by inlining thev1
namespace).We observed this behavior at the following PR to CCCL/CUB: https://github.com/NVIDIA/cccl/pull/1688
I therefore think that header-only libraries must not define
NVTX3_CPP_REQUIRE_EXPLICIT_VERSION
to not break user code. Please correct me if I am wrong. Otherwise, I would kindly ask you to update the guidance provided by the documentation.