mid.cpp: Replace std::to_string with compatible solution#176
Conversation
|
last alternative would be to have a sub switch with different text? |
|
I think, showing just 'Type 0' or 'Type 1' would be enough. Any other objections? |
|
Type 2 files definitely exist although rare, so you'd need to be able to handle that too. If you want to do it in a true cross-platform manner, in a way that will work regardless of which character set is in use, you'll probably have to use string streams. I used this macro in Camoto, you are welcome to borrow it: Then you would write: It's probably only worth doing this though if there are a number of different places you can use it, across multiple files. It's probably overkill for just a single use. |
|
Maybe a compromise that doesn't assume ASCII but also doesn't pull in BTW, the readme still mentions that AdPlug is "currently tested" with GCC 4.1, which evidently cannot be true. Maybe that information should be removed... |
|
tweak from @sagamusix is more readable, and with a comment perhaps about why we do it. return std::string("General MIDI (type " + std::string(1, '0' + midi_type) + ")"); // avoid using std::to_string(midi_type) which is c++11 ```
I also added a issue about that testing currently does not test gcc 4.1, this detail probably has been missing since adplug was migrated to github |
|
I've updated the PR as @mywave82 suggested. https://stackoverflow.com/questions/12975341/to-string-is-not-a-member-of-std-says-g-mingw |
|
Thank you for the patience |
Trivia: older mingw/gcc 4.8.x versions don't have std::to_string implementation.
And since to_string is used only in one sole case in mid.cpp to show the midi_type value, it can be safely replaced with compatible solution.
'midi_type' can hold 0, 1 or 2 only, so we should care only about these values.
Why bother? There are still some cross-toolchains that are nailed to old gcc versions that won't be ever updated. The rest of the code is absolutely 4.8.x compliant, so why not make it slightly more compatible?