schellingb / TinySoundFont

SoundFont2 synthesizer library in a single C/C++ file
MIT License
608 stars 71 forks source link

tml.h depends on struct tsf_stream definition #42

Closed Lyatus closed 4 years ago

Lyatus commented 4 years ago

Hello,

I'm currently working on a project in which I use TinyMidiLoader as a standalone lib (thanks!), and I'm encountering some problems with gcc complaining about tml_load_tsf_stream, here's the related output:

In file included from rbncli.c:9:
tml.h:469:48: warning: ‘struct tsf_stream’ declared inside parameter list will not be visible outside of this definition or declaration
 TMLDEF tml_message* tml_load_tsf_stream(struct tsf_stream* stream)
                                                ^~~~~~~~~~
tml.h:469:21: error: conflicting types for ‘tml_load_tsf_stream’
 TMLDEF tml_message* tml_load_tsf_stream(struct tsf_stream* stream)
                     ^~~~~~~~~~~~~~~~~~~
In file included from rbncli.h:7,
                 from rbncli.c:1:
tml.h:141:21: note: previous declaration of ‘tml_load_tsf_stream’ was here
 TMLDEF tml_message* tml_load_tsf_stream(struct tsf_stream* stream);
                     ^~~~~~~~~~~~~~~~~~~

struct tsf_stream doesn't seem to be declared in TinyMidiLoader and is assumed to have been declared earlier in tsf.h. I figure to fix this problem you could move it out of tml.h (or remove it, considering it's only a simple cast) or you could compile it conditionally (from tsf.h defines). I could define a dummy struct tsf_stream in my code to avoid the problem or remove the code from your lib, but it's client-side friction probably best avoided. Do you have any other suggestion? Thanks again for your work!

schellingb commented 4 years ago

Hi there

Thank you for noticing and reporting this! I just committed the fix e1aa807 for this. Guess you're the first to use tml.h standalone (or everyone works in C++ where this is no issue).

Thanks again and cheers!

Lyatus commented 4 years ago

Great! Thank you for fixing it so quickly :)