Simple header file for detecting OS
Find a file
2026-08-08 11:24:46 -04:00
is_os.h Expand BSD macros, add OS_GNUHURD 2026-08-08 11:24:46 -04:00
LICENSE Initial Check-In 2026-08-08 09:16:09 -04:00
README.md Expand BSD macros, add OS_GNUHURD 2026-08-08 11:24:46 -04:00

IS OS

C Macro Project

Very, very basic header to determine which DESKTOP OS is being targetted.

I have several command-line projects that I make sure compile on Windows and UNIX-likes. I've grown tired of rewriting these detection macros over and over again across projects.

SET MACRO

  • IS_OS_H
    • This is always set when an OS has been successfully detected.
  • OS_WIN
    • This is set when Microsoft Windows is the target
  • OS_LINUX
    • This is set when a Linux distribution is the target
  • OS_BSD
    • This is set when a BSD distribution is the target
  • OS_GNUHURD
    • This is set when a GNU/HURD distribution is the target
  • OS_MAC
    • This is set when MacOS is the target
  • OS_UNIX
    • This is set when a Linux distribution is the target

Error

If an OS cannot be detected, the #error pragma is invoked.

License

MIT