# CBE: \`\#undef linux\` in zig.h · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/71ca0b176f7a643ef7606d12f4001b445a115092)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 71ca0b176f7a643ef7606d12f4001b445a115092

Requested commit: 71ca0b176f7a643ef7606d12f4001b445a115092

Commit: 71ca0b176f7a643ef7606d12f4001b445a115092

Tree: f82bc251747118af19726b0e5d5f947fd1206699

Author: Daniele Cocca

Committer: Daniele Cocca

## Message

```
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

```

## Parents

- [79f74943b525daa06f2b2c3d460da97a88aee5bb](https://git.cafe/gitcafe/zig/commit/79f74943b525daa06f2b2c3d460da97a88aee5bb?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/71ca0b176f7a643ef7606d12f4001b445a115092?format=markdown)
