Skip to content

[libc] casting macro for user headers #127238

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

Closed
nickdesaulniers opened this issue Feb 14, 2025 · 2 comments
Closed

[libc] casting macro for user headers #127238

nickdesaulniers opened this issue Feb 14, 2025 · 2 comments
Labels

Comments

@nickdesaulniers
Copy link
Member

@enh-google saw our endian.h and mentioned __BIONIC_CAST.
https://android.googlesource.com/platform/bionic/+/main/libc/include/sys/cdefs.h#57

#if defined(__cplusplus)
#define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v))
#else
#define __BIONIC_CAST(_k,_t,_v) ((_t) (_v))
#endif

maybe interesting to add that to libc/include/__llvm-libc-common.h and use more in our user facing headers.

@llvmbot
Copy link
Member

llvmbot commented Feb 14, 2025

@llvm/issue-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

@enh-google saw our endian.h and mentioned `__BIONIC_CAST`. https://android.googlesource.com/platform/bionic/+/main/libc/include/sys/cdefs.h#57 ```c++ #if defined(__cplusplus) #define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v)) #else #define __BIONIC_CAST(_k,_t,_v) ((_t) (_v)) #endif ``` maybe interesting to add that to libc/include/__llvm-libc-common.h and use more in our user facing headers.

c8ef added a commit that referenced this issue Feb 19, 2025
related: #127238

This patch adds a macro called `LLVM_LIBC_CAST`, similar to
`__BIONIC_CAST`, for type conversion in `endian.h`.
@c8ef
Copy link
Contributor

c8ef commented Mar 4, 2025

Since the patch has landed, I believe we can now close this issue :-)

@c8ef c8ef closed this as completed Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants