Skip to content

Commit e9355b1

Browse files
authored
[libc] Use __SIZEOF_LONG__ to define LONG_WIDTH instead of sizeof(long). (#79391)
The standard requires `limits.h` constants to be used in preprocessors. So we use `__SIZEOF_LONG__` instead of `sizeof(long)` to define `LONG_WIDTH`. The macro `__SIZEOF_LONG__` seems to be available on both clang and gcc since at least version 9.
1 parent bb6a485 commit e9355b1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libc/include/llvm-libc-macros/limits-macros.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@
7070
#elif defined(__WORDSIZE)
7171
#define LONG_WIDTH __WORDSIZE
7272
#else
73-
// Use sizeof(long) * CHAR_BIT as backup. This is needed for clang-13 or before.
74-
#define LONG_WIDTH (sizeof(long) * CHAR_BIT)
73+
// Use __SIZEOF_LONG__ * CHAR_BIT as backup. This is needed for clang-13 or
74+
// before.
75+
#define LONG_WIDTH (__SIZEOF_LONG__ * CHAR_BIT)
7576
#endif // __LONG_WIDTH__
7677
#endif // LONG_WIDTH
7778

0 commit comments

Comments
 (0)