[PATCH] D130800: [clang][Headers] Avoid compiler warnings in builtin headers

Dominic Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 2 21:26:52 PDT 2022


ddcc 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:
> 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)
I'm a little reluctant to change this file too much since it's tedious and error-prone, but yeah if we can agree on a solution, I can go ahead and make the change.


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