Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

is std::trunc() ever going to work?

29 views
Skip to first unread message

janezz55

unread,
Oct 22, 2022, 5:11:21 AM10/22/22
to
I tried to use std::trunc(), but it doesn't work and browsing through header files revealed gcc does not trust the math.h header file DJGPP provides and so does not declare it. trunc(), truncf(), truncl() work as expected though.

the error is:

error: 'trunc' is not a member of 'std'; did you mean 'trunc'?
/usr/i586-pc-msdosdjgpp/include/math.h:195:15: note: 'trunc' declared here
195 | extern double trunc(double);

apparently the macro __CORRECT_ISO_CPP11_MATH_H_PROTO_FP is not defined. Defining it explicitly produces errors related to isnan().

Documentation about the macro says: Define if all C++11 floating point overloads are available in <math.h>.

jwt27

unread,
Nov 23, 2022, 3:24:12 PM11/23/22
to
For some reason this message never showed up in my mailbox, I only just
see it now on NNTP.

The issue is that djgpp does not implement all C99 math functions, so
libstdc++ just disables all of them. You can of course use ::trunc()
from libc or __builtin_trunc() (with f/l suffix where appropriate).

janezz55

unread,
Nov 23, 2022, 9:05:29 PM11/23/22
to
> The issue is that djgpp does not implement all C99 math functions, so
> libstdc++ just disables all of them. You can of course use ::trunc()
> from libc or __builtin_trunc() (with f/l suffix where appropriate).

I know the workaround already. Hopefully someone will write a patch for this quirk.
0 new messages