• Re: OS Macros

    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)