Closed musicinmybrain closed 3 years ago
Out of curiosity, which library is used ?
This was on Fedora Rawhide (development version) with gcc 11.1.1 and glibc 2.33.9000 (a pre-relase for glibc 2.34), and -std=c89
to verify C89 compatibility.
The fact that dr_mp3.h
uses int32_t
without otherwise requiring C99 support and without including stdint.h
or inttypes.h
is an issue regardless of the particular platform. There might exist some platforms where you can get away with it, especially in C99 mode. For example, on some platforms stddef.h
, stdlib.h
, or limits.h
might recursively include some header that defines the int32_t
type.
Since there is already a drmp3_int32
type in the header, and the affected function already uses it elsewhere, this seems like an obvious remedy with no disadvantages.
OK I see, then the initial comment is misleading: glibc obviously can do c99+, only thing is that dr_mp3.h isn't including stdint.h.
Ok, I see the misunderstanding. When I say “the library is C89,” I mean the library dr_mp3
is targeting C89 compatibility without assuming C99 or platform extensions. I say that based on the fact that it already puts significant effort into defining fixed-length integer types without including C99 headers stdint.h
or inttypes.h
, and based on the practice of compiling test code as C89 in https://github.com/mackron/dr_libs/blob/master/tests/build_flac_linux.sh and similar.
Thanks for the report and pull request. I've merged all of your PRs into the dev branch and will release to the master branch soon.
In
dr_mp3.h
, theint32_t
type is used on ARMv6:Since the library is C89 without
stdint.h
/inttypes.h
, this type is unknown and the build fails:The appropriate fix seems to be to replace the
int32_t
parameter with andrmp3_int32
one; this type is already used in the function body and the function return value. I have confirmed this solves the problem, so I will follow up with a PR.