adtools icon indicating copy to clipboard operation
adtools copied to clipboard

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

Open AV00 opened this issue 7 years ago • 1 comments

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 avatar Jul 19 '18 11:07 AV00

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.

AV00 avatar Jul 20 '18 10:07 AV00