• OS Macros

    From Michael Sanders@3:633/10 to All on Thu Jan 8 15:56:15 2026
    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

    --- PyGate Linux v1.5.2
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Thu Jan 8 20:11:57 2026
    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 ?Unix? support in
    Apple?s OS ...

    #ifdef _WIN32
    #ifdef _WIN64

    Actually there is no ?Win64?. There is some kind of 64-bit adaptation
    of ?Win32?, but it?s still just ?Win32? ...

    --- PyGate Linux v1.5.2
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Thu Jan 8 20:21:45 2026
    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 ?Unix? support in
    Apple?s OS ...

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


    --- PyGate Linux v1.5.2
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From John McCue@3:633/10 to All on Sun Jan 11 23:56:37 2026
    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

    --- PyGate Linux v1.5.2
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From John McCue@3:633/10 to All on Sun Jan 11 23:53:00 2026
    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

    --- PyGate Linux v1.5.2
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Mon Jan 12 07:12:46 2026
    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.

    --- PyGate Linux v1.5.2
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From John McCue@3:633/10 to All on Tue Jan 13 21:46:05 2026
    Kenny McCormack <gazelle@shell.xmission.com> wrote:
    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.

    Correct, a typo. Thanks

    --
    [t]csh(1) - "An elegant shell, for a more... civilized age."
    - Paraphrasing Star Wars

    --- PyGate Linux v1.5.2
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)