[clang] ef8121b - [Headers] Remove a space in NULL define

Heejin Ahn via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 17:23:15 PDT 2023


Author: Heejin Ahn
Date: 2023-08-31T17:22:44-07:00
New Revision: ef8121b109ef0be9fe94289acbfb9736d66cff15

URL: https://github.com/llvm/llvm-project/commit/ef8121b109ef0be9fe94289acbfb9736d66cff15
DIFF: https://github.com/llvm/llvm-project/commit/ef8121b109ef0be9fe94289acbfb9736d66cff15.diff

LOG: [Headers] Remove a space in NULL define

There was no space in `((void *)0)` before D158709. This can cause
downstream warnings in case other libraries define `NULL` as
`((void*)0)`, which is the case for [[ https://www.musl-libc.org/ | musl ]]. (see `NULL` definition in
https://git.musl-libc.org/cgit/musl/tree/include/stdio.h)

When a macro is redefined, if the content is the same it is fine, but if
it is different even in terms of a single space, clang warns:
```
../musl/include/stdio.h:37:9: error: 'NULL' macro redefined [-Werror,-Wmacro-redefined]
   37 | #define NULL ((void*)0)
      |         ^
```

The old code didn't have the space and it had been fine for many years,
so I think there's no risk in removing it. The linter seems to prefer
the space in there, but I think it has a risk of causing warnings or
even errors for downstream users.

Reviewed By: iana

Differential Revision: https://reviews.llvm.org/D159312

Added: 
    

Modified: 
    clang/lib/Headers/__stddef_null.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/__stddef_null.h b/clang/lib/Headers/__stddef_null.h
index 33d0ec62fd905da..6244964ac871fea 100644
--- a/clang/lib/Headers/__stddef_null.h
+++ b/clang/lib/Headers/__stddef_null.h
@@ -15,5 +15,9 @@
 #define NULL 0
 #endif
 #else
-#define NULL ((void *)0)
+// Don't add any whitespaces in ((void*)0) below!
+// musl (https://www.musl-libc.org/) redefines `NULL` as such and redefinition
+// with a 
diff erent expression, even in terms of a single whitespace, causes a
+// warning.
+#define NULL ((void*)0)
 #endif


        


More information about the cfe-commits mailing list