libmpg123 fails to compile with MSVC for WIN64.
Reason:
readers.c includes both mpg123.h and compat.h.
mpg123.h (mpg123.h.in in fact) has:
#if defined(_MSC_VER)
#include <stddef.h>
typedef ptrdiff_t ssize_t;
#endif
compat.h has:
#ifdef _MSC_VER
typedef long ssize_t;
#endif
With MSVC (VS2015) x86, ptrdiff_t is int. This causes a warning but no error with the conflicting typedef of ssize_t to long:
src\libmpg123\mpg123.h.in(47): warning C4142: 'ssize_t': benign redefinition of type
src\compat\compat.h(105): note: see declaration of 'ssize_t'
With MSVC (VS2015) when _WIN64 is defined however, ptrdiff_t is __int64 and thus causes an error because now the 2 typedefs of ssize_t result in differently sized types (long is 32bit on 64bit Windows):
src\libmpg123\mpg123.h.in(47): error C2371: 'ssize_t': redefinition; different basic types
src\compat\compat.h(105): note: see declaration of 'ssize_t'
As size_t is typedefed to unsigned int or unsigned __int64, and ptrdiff_t is typedefed to int or __int64 (for 32bit and 64bit respectlively) by MSVC, and ssize_t should be the signed variant of size_t, the typedef of ssize_t to ptrdiff_t is the correct one.
compat.h needs to be changed to also have
typedef ptrdiff_t ssize_t;
instead of
typedef long ssize_t;
.
Ah, thanks for pointing out that blunder. I made the definitions consistent now and also added a guard to ensure we don't do typedef twice (which may not disturb MSVC itself, though, but seems proper).
Are you successful with a MSVC 2016 build now? We might need an updated project file for the upcoming release …
I can successfully build libmpg123 svn trunk with MSVC 2015 with my own build system now.
I am not using the project files provided by mpg123 (or generally any other 3rd party library that I am using) because it is easier for me to include multiple 3rd party libraries when using consistently generated project files accross all libraries. Thus, I do not care particularly much about to mpg123 MSVC project files.
Having a quick look at the VS2015 project files though:
src\libmpg123\mangle.h(14): fatal error C1083: Cannot open include file: 'intsym.h': No such file or directory. Probably needs some include path in the command line.Yeah, I know that the project file is broken;-) As we don't test this, I have to wonder if I should drop it from the source releases. Perhaps those untested ports are better kept in the repository for people grab when interested. They're starting points, not ready-to-use.
Well, at least as a starting point, the project files were actually useful for me.
We got updated project stuff in 1.24.0 now.
Diff: