[libav-devel] [PATCH] Work around a broken limits.h header on {Net, Open}BSD.

Anton Khirnov anton at khirnov.net
Thu Nov 21 19:11:28 CET 2013


On Wed, 20 Nov 2013 20:23:58 +0100, Anton Khirnov <anton at khirnov.net> wrote:
> 
> On Tue, 19 Nov 2013 13:20:22 -0800, Martynas Venckus <martynas at venck.us> wrote:
> > Thanks, Anton.
> > 
> > You can't do explicit casts as the standard mandates that those macros be
> > constant expressions.
> 
> Using a cast does not prevent it from being a constant expression. In fact the
> relevant chapter in the C99 standard (6.6) explicitly mentions casts in this
> context as permitted.
> 
> > 
> > Moreover, GCC itself exports those exact same values via __DBL_MAX
> > builtins, which are not double-precision anymore when used.  Please be sure
> > to report this to GCC.
> >
> 
> The value provided by newer gcc versions is explicitly cast to double.
> $ gcc-4.4 -dM -E - < /dev/null|grep __DBL_MAX__
> #define __DBL_MAX__ 1.7976931348623157e+308
> $ gcc-4.8 -dM -E - < /dev/null|grep __DBL_MAX__
> #define __DBL_MAX__ ((double)1.79769313486231570815e+308L)
> 
> So the problem only occurs because the value declared in your header is not
> treated as double.
> 

For the record, I've also discovered the same problem in the musl libc, and
they fixed it in commit 46db37289f917e23877a0e0df88cbb150805bc97
http://git.musl-libc.org/cgit/musl/commit/?id=46db37289f917e23877a0e0df88cbb150805bc97

-- 
Anton Khirnov


More information about the libav-devel mailing list