[PATCH] D130800: [clang][Headers] Avoid compiler warnings in builtin headers
Ian Anderson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 2 16:57:20 PDT 2022
iana added inline comments.
================
Comment at: clang/lib/Headers/stdint.h:99-100
typedef __UINT64_TYPE__ uint64_t;
+# undef __int_least64_t
# define __int_least64_t int64_t
+# undef __uint_least64_t
----------------
iana wrote:
> What are you seeing that's defining `__int_least64_t` and all these other ones by the time you get here? It's surprising to me that so much preprocessor state exists when you hit this point considering that this file doesn't include anything else. Is this some kind of artifact with how the OS module map is making a module for stdint.h?
Oh I see, it's not these ones that are the problem, it's the redefinitions below. I guess it's a bigger change, but I wonder if flipping the order would be cleaner? e.g.
```
#ifdef __INT32_TYPE__
# define __int_least32_t int32_t
#endif
#ifdef __INT64_TYPE__
# ifndef __int_least32_t
# define __int_least32_t int64_t
# endif
#endif
```
I guess it's an extra line per type doing it that way, but maybe it's more obvious? (Maybe I just don't do a lot of preprocessor programming, but `#undef` feels like a code smell to me)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130800/new/
https://reviews.llvm.org/D130800
More information about the cfe-commits
mailing list