Skip to content

Macro redefinition warnings - #144

Merged
RichardGe merged 1 commit into
mainfrom
feature/ORO-0-fix-hip-macro-redefinition-warnings
Aug 18, 2026
Merged

Macro redefinition warnings#144
RichardGe merged 1 commit into
mainfrom
feature/ORO-0-fix-hip-macro-redefinition-warnings

Conversation

@meistdan

Copy link
Copy Markdown
Collaborator

This PR resolves macro redefinition warnings #98

…end header

Orochi.cpp includes two headers that define the same 50 macro names with
different replacement lists. Orochi.h pulls in contrib/hipew/include/hipew.h,
which defines the HIP-native values (hipEventDefault 0x0, hipStreamPerThread
((hipStream_t)2), __dparm(x) empty). nvidia_hip_runtime_api_oro.h, the HIP
SDK's CUDA back-end, then defines the same names in terms of their CUDA
equivalents (cudaEventDefault, ((cudaStream_t)2), __dparm(x) = x). Every one
of them produced a C4005 warning when OROCHI_ENABLE_CUEW is defined.

The collision was already resolving to the CUDA spellings, since the last
definition wins and those are the ones the CU4ORO namespace needs, so this
only removes the diagnostics and leaves the preprocessor output unchanged.

Drop the hipew mapping with an #undef block immediately before the include,
mirroring the existing cuew #undef block at the top of the namespace. The
list is exactly the 50-name intersection of the two headers' #define sets:
no misses, no over-reach. All 50 are unconditionally redefined by the CUDA
header afterwards, so none are left dangling; __dparm is defined in both
branches of its #ifdef __cplusplus. Nothing after the include uses the hipew
spellings, and the public hipewInit declaration uses hipew__dparm, which is a
separate macro and is untouched.

Verified by compiling the directive streams extracted from both real headers
with MSVC 14.51: 49 C4005 warnings before, 0 after, no new diagnostics. The
50th, hipCooperativeLaunchMultiDeviceNoPostSync, warns only in a real build
because its definition uses a line continuation the extraction flattened.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets MSVC C4005 macro redefinition warnings observed during HIPRT compilation by adjusting preprocessor state in Orochi.cpp before including the NVIDIA HIP back-end headers.

Changes:

  • Undefines a set of HIP-side flag/utility macros (previously provided via hipew.h through Orochi.h) before including nvidia_hip_runtime_api_oro.h, preventing conflicting macro redefinitions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Orochi/Orochi.cpp
Comment on lines +810 to +814
// Orochi.h pulls in hipew.h, which defines the HIP-side spelling of these flag macros (hipEventDefault 0x0,
// hipStreamPerThread ((hipStream_t)2), __dparm(x) empty, ...). The header below is the HIP SDK's CUDA
// back-end and defines the same names in terms of their CUDA equivalents (cudaEventDefault,
// ((cudaStream_t)2), ...). Same names, different replacement lists, so every one of them was a C4005
// macro redefinition warning. The CUDA spellings are the ones this namespace needs, and they are what the
@RichardGe
RichardGe merged commit 69eaa80 into main Aug 18, 2026
2 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.

3 participants