• Page:
  • 1

TOPIC: cmath - missing functions?

cmath - missing functions? 3 months 2 weeks ago #14184

Hi!

I'm trying to use a library that's using some <cmath> functions (std::isfinite and std::signbit) but they can't be found so I get "[bcc32c Error] .... no member named 'isfinite' in namespace 'std'".

In cmath I see this, but I don't know what it means:
 #if _HAS_C9X
using _CSTD fpclassify; using _CSTD signbit;
using _CSTD isfinite; using _CSTD isinf;
 #endif /* _HAS_C9X */

I also found that the NAN macro and std::isnan function is missing when trying to implement my own functions to cover for these missing ones.

Aren't they supposed to be available? I've uninstalled and reinstalled a couple of times these last days already so I'm getting used to it if that's what it takes to get them in ... :-)

I'll try something like this to get passed these obstacles. It compiles but I haven't tested if it really does what it should:
// add clever test to see if this is really needed
namespace std {
	// integral overloads will be added if necessary
	template<typename T>
	bool signbit(T v) {
		return std::abs(v) != v;
	}
	template<typename T>
	bool isnan(T v) {
		return v != v;
	}
	template<typename T>
	bool isfinite(T v) {
		return v != INFINITE && isnan(v) == false;
	}
}

Edit:
I also noticed that std::char_traits::eof is
static int_type eof();
instead of
static constexpr int_type eof();
as it should be in C++11, which makes all the switch statements with
case std::char_traits<char>::eof():
in this library failing to compile in 10.2.1.

Br,
Ted
RAD Studio  10.2.1  32 bit
The following user(s) said Thank You: nate

Please Log in or Create an account to join the conversation.

Last Edit: by Ted.

cmath - missing functions? 2 months 1 week ago #14809

Find out how to use? I would like to use this functions too.

Please Log in or Create an account to join the conversation.

cmath - missing functions? 2 months 1 week ago #14820

Hi Nate!

I've made a header file including the functions needed by a json library I'm using:
cmath_missing.hpp

It's a hack - adding functions to the std namespace which shouldn't be done, but I didn't know what else to do. Right now the functions are a mix of home made functions and calls to existing Windows functions.

Example for std::signbit():
namespace std {
    template <typename T>
    bool signbit(T v) {
        return signbit((double)v);
    }
    template <>
    bool signbit(float v) {
        return *((unsigned char*)&v+3) & 0x80;
    }
    template <>
    bool signbit(double v) {
        return *((unsigned char*)&v+7) & 0x80;
    }
    template <>
    bool signbit(long double v) {
        return *((unsigned char*)&v+9) & 0x80;
    }
}

I will not work as-is on _WIN64 or any other platform than _WIN32 but you're welcome to try it out (by removing the guarding !defined(_WIN64) at the top). If you can confirm that it's working on _WIN64 I'll remove that guard.

I've also limited it to clang versions [3.3.1, 3.4.0) since I'm on Builder 10.2.1 and don't know what clang version Builder 10.2.2 and later are based on or if they have fixed proper C++11 headers in those versions.

Remove the guards and please tell me if it works and what Builder version you're on and what clang version it's based on and I'll modify the guards accordingly.

Also, it's incomplete. I've only added what I needed right now. if you need functions that I haven't added yet, please tell me and I'll try to add those too.

People with 10.2.2 or 10.2.3, do you have std::signbit and all the rest of the C++11 cmath functions and is std::char_traits::eof still defined as "static int_type eof()" instead of "static constexpr int_type eof()"?

Br,
Ted

Please Log in or Create an account to join the conversation.

cmath - missing functions? 2 months 1 week ago #14825

Just use 64Bit Target and u can use all those.

Please Log in or Create an account to join the conversation.

cmath - missing functions? 2 months 1 week ago #14839

I don't have a 64 bit Windows machine, that's why didn't dare letting people with 64 bit machines use them, but ok, I'll take your word for it and have now removed that 64 bit guard.

Please Log in or Create an account to join the conversation.

cmath - missing functions? 2 months 1 week ago #14858

.... or did you mean that the functions are only missing when compiling for 32 bit target?

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: April Anne