[clang] Ensure proper NULL macro definition for system include files. (PR #149176)

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 17 10:36:15 PDT 2025


================
@@ -0,0 +1,15 @@
+// There are at least 2 valid C null-pointer constants as defined
+// by the C language standard.
+// Test that the macro NULL is defined consistently for all platforms by
+// those headers that the C standard mandates a macro definition for NULL.
+
+// RUN: %clang %s -Dheader="<locale.h>" -E | tail -1 | FileCheck %s
+// RUN: %clang %s -Dheader="<stdio.h>" -E | tail -1 | FileCheck %s
+// RUN: %clang %s -Dheader="<stdlib.h>" -E | tail -1 | FileCheck %s
+// RUN: %clang %s -Dheader="<string.h>" -E | tail -1 | FileCheck %s
+// RUN: %clang %s -Dheader="<time.h>" -E | tail -1 | FileCheck %s
+// RUN: %clang %s -Dheader="<wchar.h>" -E | tail -1 | FileCheck %s
----------------
hubert-reinterpretcast wrote:

> There is no target specified so it will not be cross-compiling.

It's entirely possible to create a cross-compiling build where the architecture is the same but the OS is different.

Using
```
%clang_cc1 -x c++ -internal-isystem %S/Inputs/include
```
instead of `%clang` seems like part of the solution.

https://github.com/llvm/llvm-project/pull/149176


More information about the cfe-commits mailing list