Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA]: Compiler independent _CCCL_PRAGMA #2601

Closed
1 task done
DejvBayer opened this issue Oct 20, 2024 · 0 comments · Fixed by #2610
Closed
1 task done

[FEA]: Compiler independent _CCCL_PRAGMA #2601

DejvBayer opened this issue Oct 20, 2024 · 0 comments · Fixed by #2610
Labels
feature request New feature or request.

Comments

@DejvBayer
Copy link
Contributor

Is this a duplicate?

Area

General CCCL

Is your feature request related to a problem? Please describe.

In the code base, for MSVC it is prefered to use __pragma over standard _Pragma. This leads to code duplication in many cases.

Describe the solution you'd like

Provide compiler independent _CCCL_PRAGMA macro implemented as (or something similar):

#define _CCCL_STRINGIFY2(x) #x
#define _CCCL_STRINGIFY(x) _CCCL_STRINGIFY2(x)

#ifdef _CCCL_COMPILER_MSVC
#  define _CCCL_PRAGMA(x) __pragma(x)
#else
#  define _CCCL_PRAGMA(x) _Pragma(_CCCL_STRINGIFY(x))
#endif

It may be used as:

#ifdef _CCCL_COMPILER_MSVC
_CCCL_PRAGMA(message("Hi from MSVC"))
#else
_CCCL_PRAGMA(message "Hi from other compiler")
#endif

Describe alternatives you've considered

No response

Additional context

No response

@DejvBayer DejvBayer added the feature request New feature or request. label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant