aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniele Cocca <daniele.cocca@gmail.com>2022-03-15 18:45:02 +0000
committerDaniele Cocca <daniele.cocca@gmail.com>2022-03-15 19:05:15 +0000
commit71ca0b176f7a643ef7606d12f4001b445a115092 (patch)
treef82bc251747118af19726b0e5d5f947fd1206699 /src
parent79f74943b525daa06f2b2c3d460da97a88aee5bb (diff)
downloadzig-71ca0b176f7a643ef7606d12f4001b445a115092.tar.gz
zig-71ca0b176f7a643ef7606d12f4001b445a115092.zip
CBE: `#undef linux` in zig.h
Compilers will sometimes `#define linux 1` if the operating system in use is Linux. This clashes with the code produced by the C backend when processing the stdlib, e.g. std.Target.Os.VersionRange [^1] which is a struct containing a field named `linux`. The output of the C backend doesn't rely on this macro being defined, and other code also shouldn't rely on it -- e.g. quoting from the GCC documentation [^2]: """ The C standard requires that all system-specific macros be part of the reserved namespace. All names which begin with two underscores, or an underscore and a capital letter, are reserved for the compiler and library to use as they wish. However, historically system-specific macros have had names with no special prefix; for instance, it is common to find unix defined on Unix systems. [...] We are slowly phasing out all predefined macros which are outside the reserved namespace. You should never use them in new programs, and we encourage you to correct older code to use the parallel macros whenever you find it. We don’t recommend you use the system-specific macros that are in the reserved namespace, either. It is better in the long run to check specifically for features you need """ [^1]: https://github.com/ziglang/zig/blob/8c32d989c995f8675f1824fb084245b833b26223/lib/std/target.zig#L224 [^2]: https://gcc.gnu.org/onlinedocs/cpp/System-specific-Predefined-Macros.html#System-specific-Predefined-Macros
Diffstat (limited to 'src')
-rw-r--r--src/link/C/zig.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/link/C/zig.h b/src/link/C/zig.h
index ce22b5221f..7259ba19ce 100644
--- a/src/link/C/zig.h
+++ b/src/link/C/zig.h
@@ -1,3 +1,5 @@
+#undef linux
+
#if __STDC_VERSION__ >= 201112L
#define zig_noreturn _Noreturn
#define zig_threadlocal thread_local