Преглед изворни кода

LibC: Make SIZE_MAX be understood by the preprocessor

POSIX mandates that the macros contained in `stdint.h` be suitable for
use by the C preprocessor.

If we write `((size_t)-1)`, the C preprocessor will just skip the cast
and treat the value as `-1`. This means that we end up taking the wrong
branch in an `#if` directive like `#if SIZE_MAX > UINT32_MAX`.

This fixes building the LLVM port on i686.
Daniel Bertalan пре 3 година
родитељ
комит
87d548c520
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      Userland/Libraries/LibC/bits/stdint.h

+ 1 - 1
Userland/Libraries/LibC/bits/stdint.h

@@ -132,7 +132,7 @@ typedef __INTMAX_TYPE__ intmax_t;
 #define UINT_LEAST32_MAX UINT32_MAX
 #define UINT_LEAST64_MAX UINT64_MAX
 
-#define SIZE_MAX ((size_t)-1)
+#define SIZE_MAX __SIZE_MAX__
 
 #define PTRDIFF_MAX __PTRDIFF_MAX__
 #define PTRDIFF_MIN (-__PTRDIFF_MAX__ - 1)