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

Clang pre-defined macros for C23 binary format? #81896

Closed
SchrodingerZhu opened this issue Feb 15, 2024 · 5 comments · Fixed by #82037 or #82361
Closed

Clang pre-defined macros for C23 binary format? #81896

SchrodingerZhu opened this issue Feb 15, 2024 · 5 comments · Fixed by #82037 or #82361
Labels
c23 clang:frontend Language frontend issues, e.g. anything involving "Sema" enhancement Improving things as opposed to bug fixing, e.g. new or missing feature

Comments

@SchrodingerZhu
Copy link
Contributor

Is there any plan to add pre-defined macros for binary format (b/B) similar to __UINT8_FMTx__?

Glibc has added PRIbN and PRIBN: https://github.com/bminor/glibc/blob/bbd248ac0d75efdef8fe61ea69b1fb25fb95b6e7/stdlib/inttypes.h#L168.

Having __UINT8_FMTb__ or __UINT8_FMTB__ will help libc to define PRIbN and PRIBN as in

@SchrodingerZhu SchrodingerZhu added question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! c23 clang:headers Headers provided by Clang, e.g. for intrinsics labels Feb 15, 2024
@shafik
Copy link
Collaborator

shafik commented Feb 15, 2024

CC @AaronBallman @cor3ntin

@AaronBallman
Copy link
Collaborator

We defer to the host system's inttypes.h:

#include_next <inttypes.h>
so it's not something I think we were planning to support directly.

@SchrodingerZhu
Copy link
Contributor Author

@AaronBallman I agree that PRIbN is definitely for posix headers.

But UINT8_FMTx is provided as builtin macro by clang. Since we have hex format already, I think it is reasonable to also have binary format.

@AaronBallman
Copy link
Collaborator

Ah, I see what you're saying, thank you! Yeah, I think that's a reasonable request.

@AaronBallman AaronBallman added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! clang:headers Headers provided by Clang, e.g. for intrinsics labels Feb 16, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 16, 2024

@llvm/issue-subscribers-clang-frontend

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Is there any plan to add pre-defined macros for binary format (`b/B`) similar to `__UINT8_FMTx__`?

Glibc has added PRIbN and PRIBN: https://github.com/bminor/glibc/blob/bbd248ac0d75efdef8fe61ea69b1fb25fb95b6e7/stdlib/inttypes.h#L168.

Having __UINT8_FMTb__ or __UINT8_FMTB__ will help libc to define PRIbN and PRIBN as in

AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Feb 16, 2024
This adds predefined formatting macros in C23 mode for printing
unsigned integers in binary format (e.g, __UINT_FAST64_FMTB__). These
are used to implement the PRIb (et al) macros in inttypes.h

Fixes llvm#81896
AaronBallman added a commit that referenced this issue Feb 16, 2024
This adds predefined formatting macros in C23 mode for printing unsigned
integers in binary format (e.g, __UINT_FAST64_FMTB__). These are used to
implement the PRIb (et al) macros in inttypes.h

Fixes #81896
AaronBallman added a commit that referenced this issue Feb 20, 2024
This adds predefined formatting macros in C23 mode for printing unsigned
integers in binary format (e.g, UINT_FAST64_FMTB). These are used to
implement the PRIb (et al) macros in inttypes.h

Fixes #81896

(Was previously reviewed in
[82037](#82037), this is fixing
some failures found post-commit.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c23 clang:frontend Language frontend issues, e.g. anything involving "Sema" enhancement Improving things as opposed to bug fixing, e.g. new or missing feature
Projects
None yet
4 participants