• OS Macros

    From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Thu Jan 8 15:56:15 2026
    From Newsgroup: comp.lang.c

    Any you'd add to this list?

    #ifdef __OpenBSD__
    #ifdef __NetBSD__
    #ifdef __FreeBSD__
    #ifdef __DragonFly__

    #ifdef __linux__
    #ifdef __linux

    #ifdef __APPLE__
    #ifdef __MACH__

    #ifdef __sun

    #ifdef _AIX
    #ifdef __hpux

    #ifdef _WIN32
    #ifdef _WIN64

    #define WIN32_LEAN_AND_MEAN // excludes rarely used stuff
    #include <windows.h> // when you include <windows.h>

    #ifdef __unix__
    #ifdef __unix
    #ifdef __POSIX__
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c on Thu Jan 8 20:11:57 2026
    From Newsgroup: comp.lang.c

    On Thu, 8 Jan 2026 15:56:15 -0000 (UTC), Michael Sanders wrote:

    #ifdef __OpenBSD__
    #ifdef __NetBSD__
    #ifdef __FreeBSD__
    #ifdef __DragonFly__

    #ifdef __linux__
    #ifdef __linux

    300-odd Linux distros can all be covered by a single ifdef, while less
    than half a dozen BSD variants each require their own.

    #ifdef __APPLE__

    I like this one from the CMake scripts for Blender:

    if(UNIX AND NOT APPLE)

    Tells you everything you need to know about the rCLUnixrCY support in
    ApplerCOs OS ...

    #ifdef _WIN32
    #ifdef _WIN64

    Actually there is no rCLWin64rCY. There is some kind of 64-bit adaptation
    of rCLWin32rCY, but itrCOs still just rCLWin32rCY ...
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c on Thu Jan 8 20:21:45 2026
    From Newsgroup: comp.lang.c

    Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
    On Thu, 8 Jan 2026 15:56:15 -0000 (UTC), Michael Sanders wrote:


    #ifdef __APPLE__

    I like this one from the CMake scripts for Blender:

    if(UNIX AND NOT APPLE)

    Tells you everything you need to know about the rCLUnixrCY support in >ApplerCOs OS ...

    No, it simply tells me that graphics are much different on
    Apple MacOS then on other unix flavors (which mostly use X11).

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From John McCue@jmclnx@gmail.com.invalid to comp.lang.c on Sun Jan 11 23:56:37 2026
    From Newsgroup: comp.lang.c

    Michael Sanders <porkchop@invalid.foo> wrote:
    Any you'd add to this list?

    #ifdef __OpenBSD__
    <snip>

    The program below was created over a long period of time.

    It has all defines I have run across on Various OSs.

    START=========================================
    /*
    prints various min/max sizes for various items
    also has defines
    */
    #ifndef COHERENT
    #ifndef _MSDOS
    #include <sys/param.h>
    #endif
    #endif

    #include <stdio.h>
    #include <limits.h>
    #include <stdlib.h>
    #ifndef LDBL_MAX
    #include <float.h>
    #endif

    /* PATH_PAX is the one to use */
    #ifdef MAXPATHLEN
    #ifndef PATH_MAX
    #define PATH_MAX MAXPATHLEN
    #endif
    #else
    #ifdef PATH_MAX
    #define MAXPATHLEN PATH_MAX
    #endif
    #endif

    #define UL "------------------------------------------------------\n"
    #define DUL "======================================================\n"

    void print_system()
    {
    int found = 0;

    #if defined(__LP64__)
    printf("Is 64 BIT\n");
    #else
    #ifndef _MSDOS
    printf("Is 32 BIT\n");
    #endif
    #endif
    printf("%s\n", DUL);

    #ifdef COHERENT
    printf("Is Coherent: COHERENT = %d\n", COHERENT);
    found++;
    #endif

    #ifdef _MSDOS
    printf("Is MS-DOS : _MSDOS = %d\n", _MSDOS);
    found++;
    #endif

    #ifdef linux
    printf("Is Linux: linux = %d\n", linux);
    found++;
    #endif

    #ifdef _AIX
    printf("Is AIX: _AIX = %d\n", _AIX);
    found++;
    #endif

    #ifdef __FreeBSD_version
    printf("Is FreeBSD: __FreeBSD_version = %d\n", __FreeBSD_version);
    found++;
    #endif

    #ifdef __NetBSD_Version__
    printf("Is NetBSD: __NetBSD_Version__ = %d\n", __NetBSD_Version__);
    found++;
    #endif

    #ifdef OpenBSD
    printf("Is OpenBSD: OpenBSD = %d\n", OpenBSD);
    found++;
    #endif

    if (found < 1)
    printf("***** UNKNOWN SYSTEM\n");

    fprintf(stdout, DUL);

    } /* print_system() */

    int main()
    {
    print_system();

    /* PATH */
    fprintf(stdout, DUL);
    fprintf(stdout, "Max PATH / File Name\n");
    fprintf(stdout, UL);
    #ifdef PATH_MAX
    fprintf(stdout, "%d\n", PATH_MAX);
    #else
    fprintf(stdout, "Need to find PATH_MAX\n");

    #endif
    fprintf(stdout, DUL);

    /* CHAR */
    fprintf(stdout, DUL);
    fprintf(stdout, "char min\n");
    fprintf(stdout, UL);
    #ifdef SCHAR_MIN
    fprintf(stdout, "%d\n", SCHAR_MIN);
    #else
    fprintf(stdout, "Need to find SCHAR_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "char max\n");
    fprintf(stdout, UL);
    #ifdef SCHAR_MAX
    fprintf(stdout, "%d\n", SCHAR_MAX);
    #else
    fprintf(stdout, "Need to find SCHAR_MAX\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned char max\n");
    fprintf(stdout, UL);
    #ifdef UCHAR_MAX
    fprintf(stdout, "%d\n", UCHAR_MAX);
    #else
    fprintf(stdout, "Need to find UCHAR_MAX\n");
    #endif

    /* short int */
    fprintf(stdout, DUL);
    fprintf(stdout, "short min\n");
    fprintf(stdout, UL);
    #ifdef SHRT_MIN
    fprintf(stdout, "%d\n", SHRT_MIN);
    #else
    fprintf(stdout, "need to find SHRT_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned short max\n");
    fprintf(stdout, UL);
    #ifdef SHRT_MAX
    fprintf(stdout, "%d\n", SHRT_MAX);
    #else
    fprintf(stdout, "need to find SHRT_MAX\n");
    #endif
    fprintf(stdout, "unsigned short max\n");
    fprintf(stdout, UL);
    #ifdef USHRT_MAX
    fprintf(stdout, "%d\n", USHRT_MAX);
    #else
    fprintf(stdout, "need to find USHRT_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* int */
    fprintf(stdout, DUL);
    fprintf(stdout, "int min\n");
    fprintf(stdout, UL);
    #ifdef INT_MIN
    fprintf(stdout, "%d\n", INT_MIN);
    #else
    fprintf(stdout, "need to find INT_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "int max\n");
    fprintf(stdout, UL);
    #ifdef INT_MAX
    fprintf(stdout, "%d\n", INT_MAX);
    #else
    fprintf(stdout, "need to find INT_MAX\n");
    #endif

    /* unsigned int */
    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned int max\n");
    fprintf(stdout, UL);
    #ifdef UINT_MAX
    fprintf(stdout, "%u\n", UINT_MAX);
    #else
    fprintf(stdout, "need to find UINT_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* long */
    fprintf(stdout, DUL);
    fprintf(stdout, "long min\n");
    fprintf(stdout, UL);
    #ifdef LONG_MIN
    fprintf(stdout, "%ld\n", LONG_MIN);
    #else
    fprintf(stdout, "need to find LONG_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "long max\n");
    fprintf(stdout, UL);
    #ifdef LONG_MAX
    fprintf(stdout, "%ld\n", LONG_MAX);
    #else
    fprintf(stdout, "need to find LONG_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* long long */
    fprintf(stdout, DUL);
    fprintf(stdout, "long long min\n");
    fprintf(stdout, UL);
    #ifdef LLONG_MIN
    fprintf(stdout, "%lld\n", LLONG_MIN);
    #else
    fprintf(stdout, "need to find LLONG_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "long long min\n");
    fprintf(stdout, UL);
    #ifdef LLONG_MAX
    fprintf(stdout, "%lld\n", LLONG_MAX);
    #else
    fprintf(stdout, "need to find LLONG_MAX\n");
    #endif

    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned long long max\n");
    fprintf(stdout, UL);
    #ifdef ULLONG_MAX
    fprintf(stdout, "%llu\n", ULLONG_MAX);
    #else
    fprintf(stdout, "need to find ULLONG_MAX\n");
    #endif

    /* DOUBLE */
    fprintf(stdout, DUL);
    fprintf(stdout, "float min\n");
    fprintf(stdout, UL);
    #ifdef FLT_MAX
    fprintf(stdout, "%f\n", -FLT_MAX);
    #else
    fprintf(stdout, "need to find FLT_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "float max\n");
    fprintf(stdout, UL);
    #ifdef FLT_MAX
    fprintf(stdout, "%f\n", FLT_MAX);
    #else
    fprintf(stdout, "need to find FLT_MAX\n");
    #endif
    fprintf(stdout, DUL);


    /* DOUBLE */
    fprintf(stdout, DUL);
    fprintf(stdout, "double min\n");
    fprintf(stdout, UL);
    #ifdef DBL_MAX
    fprintf(stdout, "%lf\n", -DBL_MAX);
    #else
    fprintf(stdout, "need to find DBL_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "double max\n");
    fprintf(stdout, UL);
    #ifdef DBL_MAX
    fprintf(stdout, "%lf\n", DBL_MAX);
    #else
    fprintf(stdout, "need to find DBL_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* LONG DOUBLE */
    fprintf(stdout, DUL);
    fprintf(stdout, "long double min\n");
    fprintf(stdout, UL);
    #ifdef LDBL_MAX
    #ifdef _MSDOS
    fprintf(stdout, "MS-DOS crashes printing -LDBL_MAX\n");
    #else
    fprintf(stdout, "%Lf\n", -LDBL_MAX);
    #endif
    #else
    fprintf(stdout, "need to find LDBL_MIN\n");
    #endif

    fprintf(stdout, DUL);
    fprintf(stdout, "long double max\n");
    fprintf(stdout, UL);
    #ifdef LDBL_MAX
    #ifdef _MSDOS
    fprintf(stdout, "MS-DOS crashes printing LDBL_MAX\n");
    #else
    fprintf(stdout, "%Lf\n", LDBL_MAX);
    #endif
    #else
    fprintf(stdout, "need to find LDBL_MAX\n");
    #endif
    fprintf(stdout, DUL);

    return(0);

    }
    END =========================================
    --
    [t]csh(1) - "An elegant shell, for a more... civilized age."
    - Paraphrasing Star Wars
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From John McCue@jmclnx@gmail.com.invalid to comp.lang.c on Sun Jan 11 23:53:00 2026
    From Newsgroup: comp.lang.c

    Michael Sanders <porkchop@invalid.foo> wrote:
    Any you'd add to this list?

    #ifdef __OpenBSD__
    <snip>

    The program below was created over a long period of time.

    It has all defines I have run across on Various OSs.

    START=========================================
    /*
    prints various min/max sizes for various items
    also has defines
    */
    #ifndef COHERENT
    #ifndef _MSDOS
    #include <sys/param.h>
    #endif
    #endif

    #include <stdio.h>
    #include <limits.h>
    #include <stdlib.h>
    #ifndef LDBL_MAX
    #include <float.h>
    #endif

    /* PATH_PAX is the one to use */
    #ifdef MAXPATHLEN
    #ifndef PATH_MAX
    #define PATH_MAX MAXPATHLEN
    #endif
    #else
    #ifdef PATH_MAX
    #define MAXPATHLEN PATH_MAX
    #endif
    #endif

    #define UL "------------------------------------------------------\n"
    #define DUL "======================================================\n"

    void print_system()
    {
    int found = 0;

    #if defined(__LP64__)
    printf("Is 64 BIT\n");
    #else
    #ifndef _MSDOS
    printf("Is 32 BIT\n");
    #endif
    #endif
    printf("%s\n", DUL);

    #ifdef COHERENT
    printf("Is Coherent: COHERENT = %d\n", COHERENT);
    found++;
    #endif

    #ifdef _MSDOS
    printf("Is MS-DOS : _MSDOS = %d\n", _MSDOS);
    found++;
    #endif

    #ifdef linux
    printf("Is Linux: linux = %d\n", linux);
    found++;
    #endif

    #ifdef _AIX
    printf("Is AIX: _AIX = %d\n", _AIX);
    found++;
    #endif

    #ifdef __FreeBSD_version
    printf("Is FreeBSD: __FreeBSD_version = %d\n", __FreeBSD_version);
    found++;
    #endif

    #ifdef __NetBSD_Version__
    printf("Is NetBSD: __NetBSD_Version__ = %d\n", __NetBSD_Version__);
    found++;
    #endif

    #ifdef OpenBSD
    printf("Is OpenBSD: OpenBSD = %d\n", OpenBSD);
    found++;
    #endif

    if (found < 1)
    printf("***** UNKNOWN SYSTEM\n");

    fprintf(stdout, DUL);

    } /* print_system() */

    int main()
    {
    print_system();

    /* PATH */
    fprintf(stdout, DUL);
    fprintf(stdout, "Max PATH / File Name\n");
    fprintf(stdout, UL);
    #ifdef PATH_MAX
    fprintf(stdout, "%d\n", PATH_MAX);
    #else
    fprintf(stdout, "Need to find PATH_MAX\n");

    #endif
    fprintf(stdout, DUL);

    /* CHAR */
    fprintf(stdout, DUL);
    fprintf(stdout, "char min\n");
    fprintf(stdout, UL);
    #ifdef SCHAR_MIN
    fprintf(stdout, "%d\n", SCHAR_MIN);
    #else
    fprintf(stdout, "Need to find SCHAR_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "char max\n");
    fprintf(stdout, UL);
    #ifdef SCHAR_MAX
    fprintf(stdout, "%d\n", SCHAR_MAX);
    #else
    fprintf(stdout, "Need to find SCHAR_MAX\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned char max\n");
    fprintf(stdout, UL);
    #ifdef UCHAR_MAX
    fprintf(stdout, "%d\n", UCHAR_MAX);
    #else
    fprintf(stdout, "Need to find UCHAR_MAX\n");
    #endif

    /* short int */
    fprintf(stdout, DUL);
    fprintf(stdout, "short min\n");
    fprintf(stdout, UL);
    #ifdef SHRT_MIN
    fprintf(stdout, "%d\n", SHRT_MIN);
    #else
    fprintf(stdout, "need to find SHRT_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned short max\n");
    fprintf(stdout, UL);
    #ifdef SHRT_MAX
    fprintf(stdout, "%d\n", SHRT_MAX);
    #else
    fprintf(stdout, "need to find SHRT_MAX\n");
    #endif
    fprintf(stdout, "unsigned short max\n");
    fprintf(stdout, UL);
    #ifdef USHRT_MAX
    fprintf(stdout, "%d\n", USHRT_MAX);
    #else
    fprintf(stdout, "need to find USHRT_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* int */
    fprintf(stdout, DUL);
    fprintf(stdout, "int min\n");
    fprintf(stdout, UL);
    #ifdef INT_MIN
    fprintf(stdout, "%d\n", INT_MIN);
    #else
    fprintf(stdout, "need to find INT_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "int max\n");
    fprintf(stdout, UL);
    #ifdef INT_MAX
    fprintf(stdout, "%d\n", INT_MAX);
    #else
    fprintf(stdout, "need to find INT_MAX\n");
    #endif

    /* unsigned int */
    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned int max\n");
    fprintf(stdout, UL);
    #ifdef UINT_MAX
    fprintf(stdout, "%u\n", UINT_MAX);
    #else
    fprintf(stdout, "need to find UINT_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* long */
    fprintf(stdout, DUL);
    fprintf(stdout, "long min\n");
    fprintf(stdout, UL);
    #ifdef LONG_MIN
    fprintf(stdout, "%ld\n", LONG_MIN);
    #else
    fprintf(stdout, "need to find LONG_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "long max\n");
    fprintf(stdout, UL);
    #ifdef LONG_MAX
    fprintf(stdout, "%ld\n", LONG_MAX);
    #else
    fprintf(stdout, "need to find LONG_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* long long */
    fprintf(stdout, DUL);
    fprintf(stdout, "long long min\n");
    fprintf(stdout, UL);
    #ifdef LLONG_MIN
    fprintf(stdout, "%lld\n", LLONG_MIN);
    #else
    fprintf(stdout, "need to find LLONG_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "long long min\n");
    fprintf(stdout, UL);
    #ifdef LLONG_MAX
    fprintf(stdout, "%lld\n", LLONG_MAX);
    #else
    fprintf(stdout, "need to find LLONG_MAX\n");
    #endif

    fprintf(stdout, DUL);
    fprintf(stdout, "unsigned long long max\n");
    fprintf(stdout, UL);
    #ifdef ULLONG_MAX
    fprintf(stdout, "%llu\n", ULLONG_MAX);
    #else
    fprintf(stdout, "need to find ULLONG_MAX\n");
    #endif

    /* DOUBLE */
    fprintf(stdout, DUL);
    fprintf(stdout, "float min\n");
    fprintf(stdout, UL);
    #ifdef FLT_MAX
    fprintf(stdout, "%f\n", -FLT_MAX);
    #else
    fprintf(stdout, "need to find FLT_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "float max\n");
    fprintf(stdout, UL);
    #ifdef FLT_MAX
    fprintf(stdout, "%f\n", FLT_MAX);
    #else
    fprintf(stdout, "need to find FLT_MAX\n");
    #endif
    fprintf(stdout, DUL);


    /* DOUBLE */
    fprintf(stdout, DUL);
    fprintf(stdout, "double min\n");
    fprintf(stdout, UL);
    #ifdef DBL_MAX
    fprintf(stdout, "%lf\n", -DBL_MAX);
    #else
    fprintf(stdout, "need to find DBL_MIN\n");
    #endif
    fprintf(stdout, DUL);
    fprintf(stdout, "double max\n");
    fprintf(stdout, UL);
    #ifdef DBL_MAX
    fprintf(stdout, "%lf\n", DBL_MAX);
    #else
    fprintf(stdout, "need to find DBL_MAX\n");
    #endif
    fprintf(stdout, DUL);

    /* LONG DOUBLE */
    fprintf(stdout, DUL);
    fprintf(stdout, "long double min\n");
    fprintf(stdout, UL);
    #ifdef LDBL_MAX
    #ifdef _MSDOS
    fprintf(stdout, "MS-DOS crashes printing -LDBL_MAX\n");
    #else
    fprintf(stdout, "%Lf\n", -LDBL_MAX);
    #endif
    #else
    fprintf(stdout, "need to find LDBL_MIN\n");
    #endif

    fprintf(stdout, DUL);
    fprintf(stdout, "long double max\n");
    fprintf(stdout, UL);
    #ifdef LDBL_MAX
    #ifdef _MSDOS
    fprintf(stdout, "MS-DOS crashes printing LDBL_MAX\n");
    #else
    fprintf(stdout, "%Lf\n", LDBL_MAX);
    #endif
    #else
    fprintf(stdout, "need to find LDBL_MAX\n");
    #endif
    fprintf(stdout, DUL);

    return(0);

    }
    END =========================================
    --
    [t]csh(1) - "An elegant shell, for a more... civilized age."
    - Paraphrasing Star Wars
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From gazelle@gazelle@shell.xmission.com (Kenny McCormack) to comp.lang.c on Mon Jan 12 07:12:46 2026
    From Newsgroup: comp.lang.c

    In article <10k1dbl$9uho$1@dont-email.me>,
    John McCue <jmclnx@gmail.com.invalid> wrote:
    ...
    The program below was created over a long period of time.

    It has all defines I have run across on Various OSs.
    ...
    /* PATH_PAX is the one to use */

    Shouldn't that be PATH_MAX ?

    Other than that, this looks good.
    --
    Nov 4, 2008 - the day when everything went
    from being Clinton's fault to being Obama's fault.
    --- Synchronet 3.21a-Linux NewsLink 1.2