[PATCH] D159312: [Headers] Remove a space in NULL define

Heejin Ahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 14:43:47 PDT 2023


aheejin created this revision.
aheejin added reviewers: iana, dschuff.
Herald added a subscriber: wingo.
Herald added a project: All.
aheejin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There was no space in `((void *)0)` before D158709 <https://reviews.llvm.org/D158709>. This can cause
downstream warnings in case other libraries define `NULL` as
`((void*)0)`, which is the case for 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//nclude/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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159312

Files:
  clang/lib/Headers/__stddef_null.h


Index: clang/lib/Headers/__stddef_null.h
===================================================================
--- clang/lib/Headers/__stddef_null.h
+++ clang/lib/Headers/__stddef_null.h
@@ -15,5 +15,5 @@
 #define NULL 0
 #endif
 #else
-#define NULL ((void *)0)
+#define NULL ((void*)0)
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159312.555171.patch
Type: text/x-patch
Size: 293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230831/c912a456/attachment.bin>


More information about the cfe-commits mailing list