Skip to content

Only define the __PRETTY_FUNCTION__ fallback on MSVC - #57

Merged
iwald-nvidia merged 1 commit into
NVIDIA:mainfrom
jjcasmar:fix-pretty-function-redefinition
Nov 2, 2026
Merged

iwald-nvidia merged 1 commit into
NVIDIA:mainfrom
jjcasmar:fix-pretty-function-redefinition

Conversation

@jjcasmar

@jjcasmar jjcasmar commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #56.

GCC and Clang provide __PRETTY_FUNCTION__ as a predefined identifier, not a macro, so the #ifndef __PRETTY_FUNCTION__ guard in cuBQL/math/common.h was always true and redefined it as __FUNCTION__ in every translation unit that included cuBQL.

The fallback now only applies to MSVC (excluding clang-cl, which has the builtin), and maps to __FUNCSIG__, MSVC's equivalent. The unreachable defined(__func__) branch is gone, since __func__ is not a macro on any compiler either.

Tested on Linux:

  • The f<int>() repro from math/common.h redefines __PRETTY_FUNCTION__ on GCC and Clang #56 prints void f() [with T = int] with GCC 13.3 and nvcc 13.0, and void f() [T = int] with Clang 18.1 (before: f).
  • #include <cuda/memory_pool> after <cuBQL/bvh.h> with CCCL 3.2 and g++ -std=c++20 now compiles; before, it failed with the typeid.h / string_view.h errors from the issue.

Not tested on MSVC.

GCC and Clang provide __PRETTY_FUNCTION__ as a predefined identifier,
not a macro, so the #ifndef guard was always true and every file that
included cuBQL had __PRETTY_FUNCTION__ replaced by __FUNCTION__. That
dropped the signature from the string and broke headers that parse it,
such as CCCL's cuda::std typeid when <cuda/memory_pool> is included
after cuBQL.

Restrict the fallback to MSVC (excluding clang-cl, which has the
builtin) and map it to __FUNCSIG__, the MSVC equivalent.

Fixes NVIDIA#56

Signed-off-by: Juan Jose Casafranca <juan@scenix.ai>
@iwald-nvidia

Copy link
Copy Markdown
Collaborator

thank you! going to merge the moment CI is done. I'll also need to check that in barney and a few other projects as well then :-)

@iwald-nvidia
iwald-nvidia merged commit a7c1072 into NVIDIA:main Nov 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

math/common.h redefines __PRETTY_FUNCTION__ on GCC and Clang

2 participants