[flac-dev] Bug: incompatibility with MSVS 2005

lvqcl
Sun, 04 May 2014 10:58:06 -0000

Erik de Castro Lopo wrote:

>> because MSVS2005 doesn't provide stdint.h. According to MSDN,
>> uintptr_t is defined in "STDDEF.H and other include files".
>
> Does the rest of FLAC actually support those compilers?

Yes. I removed this #include and all projects were successfully
built with MSVS 2005 Express.

> Is it worth
> continuing to support them?

* At least Audacity team still uses VS 2008:
   http://wiki.audacityteam.org/wiki/Developing_On_Windows
* Also the latest version of Winamp was built with VS 2008. But then
   Winamp was sold to Radionomy, so who knows what tools they use now...


--------------
Why MSVS can compile memory.c when "#include <stdint.h>" was
removed:
memory.c includes "private/memory.h", it indirectly includes
<crtdefs.h>
where uintptr_t is defined. But it's implementation details...

--------------
memory.c also includes "share/alloc.h" which contains the following
code:

#if HAVE_STDINT_H
#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
#endif

but memory.c includes <stdint.h> unconditionally. What was the reason for
this #ifdef/#endif? Compatibility with non-C99 compilers?

--------------
Maybe the simplest fix for this problem is to replace

#include <stdint.h>

with

#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#include <stddef.h>
#endif

or

#ifndef _MSC_VER
#include <stdint.h>
#else
#include <stddef.h>
#endif