mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

No logging in c++ on non-msvc because of not detecting vsnprintf #500

Closed u3shit closed 2 years ago

u3shit commented 2 years ago

After updating miniaudio, I realized that logging has disappeared. It looks like in ma_log_postv it checks for the __STDC_VERSION__ macro, which is not defined when compiling in c++ mode in clang and gcc under linux. According to cppreference, vsnprintf is available since c++11, so I guess a (defined(__cplusplus) && __cplusplus >= 201103L) could be added to the #if. https://en.cppreference.com/w/cpp/io/c/vfprintf

mackron commented 2 years ago

Thanks for this. I've gone ahead and added that to the dev branch. I think I could loosen that up a bit - I would think there'd be quite a few compilers pre-c++11 that would support vsnprintf(). In any case, I'll wait for community feedback before worrying about that.