This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: strtof is not defined anymore in std=c++11
- From: Laurent Alfonsi <laurent dot alfonsi at st dot com>
- To: <newlib at sourceware dot org>
- Date: Wed, 3 Apr 2013 15:22:58 +0200
- Subject: Re: strtof is not defined anymore in std=c++11
- References: <515AB4D3 dot 8060405 at st dot com> <20130402120003 dot GC32544 at calimero dot vinschen dot de> <515B2D19 dot 10306 at dronecode dot org dot uk>
Jon,
|| (defined (__cplusplus) && __cplusplus >= 201103L)
I agree. That would be perfect.
Yes. I think that all of the protoypes I touched: strtof(), strtoll(),
strtoull() and strtold() need this attention.
Yes. It is the same for these 4 also.
As currently written, it doesn't test if __STDC_VERSION__ is defined (and so
uses the assumed value of 0 when compiling C++), so do we actually need to
test if __cplusplus is defined?
When using gcc, a macro that is not defined is always expanded as 0. see :
http://gcc.gnu.org/onlinedocs/cpp/If.html#If
So __STDC_VERSION__ >= 199901L is FALSE when __STDC_VERSION__ is not
defined,
same for __cplusplus >= 201103L. (in the context of gcc preprocessor)
Thanks,
Laurent
On 02.04.2013 21:10, Jon TURNEY wrote:
On 02/04/2013 13:00, Corinna Vinschen wrote:
On Apr 2 12:37, Laurent Alfonsi wrote:
The strtof function is now rejected when selecting the gcc C++11
standard option.
This regression has been introduced in this patch
http://sourceware.org/ml/newlib/2012/msg00425.html
J.Turney patch is fine regarding the C standard side, but when using
from C++ :
$ cat a.cpp
#include <cstdlib>
float f(const char *s, char **endptr) {
return strtof(s, endptr);
}
It fails with the message :
$ g++ -std=c++11 a.cpp
a.cpp: In function 'float f(const char*, char**)':
a.cpp:3:30: error: 'strtof' was not declared in this scope
Whereas this function strtof is well included in the cstdlib header
file defined in C++11 ISO.
Please advice.
Not sure. Enabling c++11 implies defining __STRICT_ANSI__ with gcc.
Maybe we have to add something like this to the #if's guarding the
declarations:
|| (defined (__cplusplus) && __cplusplus >= 201103L)
Yes. I think that all of the protoypes I touched: strtof(), strtoll(),
strtoull() and strtold() need this attention.
As currently written, it doesn't test if __STDC_VERSION__ is defined (and so
uses the assumed value of 0 when compiling C++), so do we actually need to
test if __cplusplus is defined?
Would you like me to write a patch?