Subject: Re: [PATCH 5/7] Define LLONG_MAX/MIN etc if not already defined.

From: Andreas Schwab <[email-masked]>
Date: Mon, 18 May 2020 12:24:00 +0200

On Mai 18 2020, Darren Tucker wrote:

> diff --git a/git-compat-util.h b/git-compat-util.h
> index 8ba576e81e..aa221eba1b 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -127,6 +127,22 @@
>  /* Approximation of the length of the decimal representation of this type. */
>  #define decimal_length(x)	((int)(sizeof(x) * 2.56 + 0.5) + 1)
>  
> +#ifndef SIZE_MAX
> +#define SIZE_MAX ((size_t)maximum_signed_value_of_type(size_t))

size_t is an unsigned type.

> +#endif
> +
> +#ifndef LLONG_MIN
> +#define LLONG_MIN ((long long)minimum_signed_value_of_type(long long))
> +#endif
> +
> +#ifndef LLONG_MAX
> +#define LLONG_MAX ((long long)maximum_signed_value_of_type(long long))
> +#endif
> +
> +#ifndef ULLONG_MAX
> +#define ULLONG_MAX ((unsigned long long)maximum_unsigned_value_of_type(unsigned long long))
> +#endif

These definitions won't work in the preprocessor.  The are no current
uses of these macros in preprocessor directives, but that needs to be
kept in mind.

Andreas.

-- 
Andreas Schwab, [email-masked]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."