Re: Successfully defining png_int_16 in pngconf.h

Cosmin Truta <[email protected]> Thu, 14 Feb 2019 22:10:37 -0500
Newsgroups gmane.comp.graphics.png.devel
Message-ID <CAAoVtZziX+arAUCrpACLPidJTsqX2d0ngOuBXuUW1vS=bx59ZA@mail.gmail.com>
On Thu, 14 Feb 2019 at 21:53, Cosmin Truta wrote:
> On Thu, 14 Feb 2019 at 21:23, Michael Enright <[email protected]> wrote:
> > In linux/kernel.h INT_MAX is defined as ((int)((~0U>>1))
>
> This is so unusual, and I conjecture that linux/kernel.h is broken. I
> need to look into the standard C, and see what it really says.

Found it: Standard C, section 5.2.4.2.1, and Standard C++, section 21.3.5.

5.2.4.2.1 Sizes of integer types <limits.h>
"The values given below shall be replaced by constant expressions
suitable for use in #if preprocessing directives."

They should fix linux/kernel.h. If that is not attainable, I hope you
can modify pngconf.h locally, in order to suit your needs.

I thought that gcc was a requirement to compile linux/kernel.h. If
that's still the case, this should not have been an issue, because gcc
has an internally-predefined macro __INT_MAX__ (and others) that can
be used.

> I always took it for granted that INT_MAX and friends are not just
> macros. They ought to be macros suitable for use in preprocessor
> conditions, before even the compile-time kicks in.

Sincerely,
Cosmin