Fixed WAV loading under 64-bit systems. #3
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
The size of the long integer type varies across operating systems and compilers. On windows, both the 32-bit and the 64-bit of Microsoft Visual C++ and MinGW use 4 bytes for integers as well as for long integers, while GCC on a 64-bit linux system makes them 8-byte long. That difference breaks the recognition of WAV file headers in
src/audio.c
under 64-bit linuces, triggering anInvalid RIFF or WAVE Header
error.To ensure compatibility in the recognition of the WAV header, it is preferable to stick to plain integers, which take four bytes under all target systems. That way, both MinGW and GCC behave the same way, regardless of the underlying OS.
Just so you can double check my reasoning, here's a short article detailing Intel's thoughts on the issue. They have their own C compiler that must remain compatible to the dominant compiler of any given platform (Visual C++ for windows, GCC for linux and macosx). MinGW shares those concerns, so the same reasoning applies.
Thanks and keep up the good work!