We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3903 - music_wav.c SamplerChunk struct
Summary: music_wav.c SamplerChunk struct
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-21 19:04 UTC by Ozkan Sezer
Modified: 2017-10-21 22:29 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2017-10-21 19:04:41 UTC
music_wav.c : SamplerChunk struct has SampleLoop loops[]; as its
last member, ancient gcc fails with it:
music_wav.c:108: field `loops' has incomplete type

Changing it to SampleLoop loops[0] (or SampleLoop loops[1]) makes
it to compile using gcc2.95, if there is interest to support this.
I can't remember how MSVC supports flexible array members.
Comment 1 Sam Lantinga 2017-10-21 19:20:04 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_mixer/rev/4bf887d61097
Comment 2 Ozkan Sezer 2017-10-21 20:16:25 UTC
It seems Watcom supports arr[] or arr[1] but not arr[0].
I suggest changing it to [1].

Or, one can define something like SDL_FLEXARRAY in SDL_stdinc.h
and use it in music_wav.c.  Something like this maybe????

#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define SDL_FLEXARRAY
#elif defined(__GNUC__) && (__GNUC__ < 3)
#define SDL_FLEXARRAY 0
#elif defined(__WATCOMC__)
#define SDL_FLEXARRAY
#else
#define SDL_FLEXARRAY 1
#endif
Comment 3 Ozkan Sezer 2017-10-21 20:40:39 UTC
Well, arr[1] is guaranteed to work with pretty much every compiler,
so I suggest simply doing that:

diff --git a/music_wav.c b/music_wav.c
--- a/music_wav.c
+++ b/music_wav.c
@@ -105,7 +105,7 @@
     Uint32  SMTPE_offset;
     Uint32  sample_loops;
     Uint32  sampler_data;
-    SampleLoop loops[0];
+    SampleLoop loops[1];
 } SamplerChunk;
 
 /*********************************************/
Comment 4 Ozkan Sezer 2017-10-21 22:12:40 UTC
Reopening so this doesn't get lost.
Comment 5 Sam Lantinga 2017-10-21 22:29:50 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_mixer/rev/2b5e37881cba