sba1 / adtools

Experimental GNU toolchain for AmigaOS
31 stars 18 forks source link

Packaged CLib2 doens't provide strtof in C++ namespace std #52

Open AV00 opened 6 years ago

AV00 commented 6 years ago

As the title says... I'm trying to use https://github.com/nlohmann/json and compilation fails with the latest Clib2 adtools-os4-clib2-20180708-690.lha and G++ (native) and compilation fails because "strtof is not a member of std".

Thanks for any help.

AV00 commented 6 years ago

There's also a similar problem with strtold() . In the supplied C++ includes it's stubbed out because the 2 C runtimes we have don't provide it in C. However, because for the target environment "long double" and "double" are absolutely the same (see macro DBL_MIN and brothers) you can simply redirect to strtod().

#ifdef __amigaos4__

//Workaround for dumb setup of includes, strtold() doesn't exist but since double and long double are the same, strtod() can be used instead!

namespace std {

static inline long double strtold(const char * a, char ** b) { return strtod(a,b);} 
}
#endif

I was thus able to compile that JSON library.