Skip to content

[Base] remove __COUNTER__ from unique_name macro (clang-22 c2y extensions)#1783

Merged
tdavidcl merged 1 commit intoShamrock-code:mainfrom
tdavidcl:fix_counter
Apr 27, 2026
Merged

[Base] remove __COUNTER__ from unique_name macro (clang-22 c2y extensions)#1783
tdavidcl merged 1 commit intoShamrock-code:mainfrom
tdavidcl:fix_counter

Conversation

@tdavidcl
Copy link
Copy Markdown
Member

@github-actions
Copy link
Copy Markdown
Contributor

Thanks @tdavidcl for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request simplifies the __shamrock_unique_name macro by removing the conditional check for __COUNTER__ and defaulting to the use of __LINE__. A review comment suggests renaming the macro to SHAMROCK_UNIQUE_NAME to avoid using double underscores, which are reserved for the implementation in C++ and could lead to name collisions.

#else
#define __shamrock_unique_name(base_name) internal_macro_sham_EXPAND2(base_name, __LINE__)
#endif
#define __shamrock_unique_name(base_name) internal_macro_sham_EXPAND2(base_name, __LINE__)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The macro name __shamrock_unique_name starts with a double underscore, which is reserved for the implementation (compiler and standard library) according to the C++ standard (and the C standard). Using reserved identifiers can lead to name collisions with compiler-defined macros or future standard library additions, potentially causing undefined behavior. It is recommended to use a prefix that does not start with a double underscore, such as SHAMROCK_UNIQUE_NAME.

Suggested change
#define __shamrock_unique_name(base_name) internal_macro_sham_EXPAND2(base_name, __LINE__)
#define SHAMROCK_UNIQUE_NAME(base_name) internal_macro_sham_EXPAND2(base_name, __LINE__)

@github-actions
Copy link
Copy Markdown
Contributor

Workflow report

workflow report corresponding to commit 8d05018
Commiter email is timothee.davidcleris@proton.me
GitHub page artifact URL GitHub page artifact link (can expire)

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
cmake-format.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
ruff check...............................................................Passed
ruff format..............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed
No UTF-8 in files (except for authors)...................................Passed

Test pipeline can run.

Clang-tidy diff report

No relevant changes found.
Well done!

You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review.

Doxygen diff with main

Removed warnings : 1
New warnings : 1
Warnings count : 8232 → 8232 (0.0%)

Detailed changes :
+ src/shambase/include/shambase/unique_name_macro.hpp:32: warning: Member __shamrock_unique_name(base_name) (macro definition) of file unique_name_macro.hpp is not documented.
- src/shambase/include/shambase/unique_name_macro.hpp:35: warning: Member __shamrock_unique_name(base_name) (macro definition) of file unique_name_macro.hpp is not documented.

@tdavidcl tdavidcl merged commit 32f3676 into Shamrock-code:main Apr 27, 2026
80 checks passed
@tdavidcl tdavidcl deleted the fix_counter branch April 27, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant