Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
43 user(s) are online (22 user(s) are browsing Forums)

Members: 1
Guests: 42

Kyle, more...

Headlines

 
  Register To Post  

(1) 2 »
No std::to_string(float) in GCC 11
Not too shy to talk
Not too shy to talk


See User information
to_string(float) is apparently supported since c++11:
https://en.cppreference.com/w/cpp/string/basic_string/to_string

I am using GCC11 : https://github.com/sodero/adtools/rele ... cc11.1.0-20210531-743.lha

I am trying to build:
type main.cpp 
#include <iostream>
#include <string>

int main()
{
    
std::string x std::to_string(22.2f);
    
std::cout<<x<<std::endl;
    return 
0;
}


4.Other:Dev/cpp11g++ -std=c++11 -athread=native -o main main.cpp 
main
.cppIn function 'int main()':
main.cpp:6:39errorcall of overloaded 'to_string(float)' is ambiguous
    6 
|         std::string x std::to_string(22.2f);
      |                         ~~~~~~~~~~~~~~^~~~~~~
In file included from /Programs/SDK/gcc/include/c++/11.1.0/string:55,
                 
from /Programs/SDK/gcc/include/c++/11.1.0/bits/locale_classes.h:40,
                 
from /Programs/SDK/gcc/include/c++/11.1.0/bits/ios_base.h:41,
                 
from /Programs/SDK/gcc/include/c++/11.1.0/ios:42,
                 
from /Programs/SDK/gcc/include/c++/11.1.0/ostream:38,
                 
from /Programs/SDK/gcc/include/c++/11.1.0/iostream:39,
                 
from main.cpp:1:
/
Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6649:3notecandidate'std::string std::__cxx11::to_string(int)'
 
6649 |   to_string(int __val)
      |   ^~~~~~~~~
/
Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6660:3notecandidate'std::string std::__cxx11::to_string(unsigned int)'
 
6660 |   to_string(unsigned __val)
      |   ^~~~~~~~~
/
Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6668:3notecandidate'std::string std::__cxx11::to_string(long int)'
 
6668 |   to_string(long __val)
      |   ^~~~~~~~~
/
Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6679:3notecandidate'std::string std::__cxx11::to_string(long unsigned int)'
 
6679 |   to_string(unsigned long __val)
      |   ^~~~~~~~~
/
Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6687:3notecandidate'std::string std::__cxx11::to_string(long long int)'
 
6687 |   to_string(long long __val)
      |   ^~~~~~~~~
/
Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6699:3notecandidate'std::string std::__cxx11::to_string(long long unsigned int)'
 
6699 |   to_string(unsigned long long __val)
      |   ^~~~~~~~~


g++ --version
g
++ (adtools build 11.1.011.1.0
Copyright 
(C2021 Free Software FoundationInc.
This is free softwaresee the source for copying conditions.  There is NO
warranty
not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Edited by rjd324 on 2022/3/17 0:18:27
Go to top
Re: No std::to_string(float) in GCC 11
Just popping in
Just popping in


See User information
@rjd324

why not use sprintf()?

Go to top
Re: No std::to_string(float) in GCC 11
Not too shy to talk
Not too shy to talk


See User information
It's a fine suggestion. Believe me, I prefer C, and could also use it here. But the question really is specific. I am wondering why it is not there for our native GCC11 compiler.

Go to top
Re: No std::to_string(float) in GCC 11
Just popping in
Just popping in


See User information
I can't say for sure, but it's likely due to something missing in clib2. Can't verify that here though. Does to_string(int) work?

Go to top
Re: No std::to_string(float) in GCC 11
Home away from home
Home away from home


See User information
@sTix

Wouldn't that be a problem in newlib?

Go to top
Re: No std::to_string(float) in GCC 11
Amigans Defender
Amigans Defender


See User information
use this code:

namespace std
{
    
template <typename Tstd::string to_string(const Tn)
    {
        
std::ostringstream stm;
        
stm << n;
        return 
stm.str();
    }
}

Go to top
Re: No std::to_string(float) in GCC 11
Just popping in
Just popping in


See User information
I had the same problem with std::to_string(int) and IIRC the solution to the problem was to compile with -std=gnu++14 instead of -std=c++14.

But then (again IIRC) the solution only worked for either OS3 or OS4 so I had to use the std::stringstream workaround that someone posted in this thread. I don't have access to my development system at the moment so I can't check.

But try -std=gnu++14 or -std=gnu++11 and see if that helps.

Go to top
Re: No std::to_string(float) in GCC 11
Just popping in
Just popping in


See User information
@Raziel
Quote:
Wouldn't that be a problem in newlib?


No, the gcc build (libstdc++v3 to be more specific) that he's using is built using clib2. I don't think it's a lot of work to fix this.

Go to top
Re: No std::to_string(float) in GCC 11
Home away from home
Home away from home


See User information
@sTix

Ah, nice.
So once we get access to the new clib2 we already have gcc11+ aswell?
Sweet...

Go to top
Re: No std::to_string(float) in GCC 11
Amigans Defender
Amigans Defender


See User information
if you only need to_string use that piece of code. It will work without any problems

Go to top
Re: No std::to_string(float) in GCC 11
Just popping in
Just popping in


See User information
@Raziel
I need to correct myself if I understand ksdhans on Github correctly. The answer to your question is yes :)

Go to top
Re: No std::to_string(float) in GCC 11
Home away from home
Home away from home


See User information
@rjd324

Just tested beta version of upcoming SDK - there all builds fine with newlib. With clib2 it ask for "wchar.h" include, which seems clib2 included with SDK does not have , and there will be needs to use Afxgroup's one, if that will be need it.

Go to top
Re: No std::to_string(float) in GCC 11
Not too shy to talk
Not too shy to talk


See User information
@kas1e

Do we have a repository of test cases for c++11 features? If this is happening for one of the new library c++11 then it may be happening for others too.

Go to top
Re: No std::to_string(float) in GCC 11
Home away from home
Home away from home


See User information
@rjd324
Quote:

Do we have a repository of test cases for c++11 features? If this is happening for one of the new library c++11 then it may be happening for others too.


Not sure that we have exactly "repo with test cases for c++11" but all the problem about GCC/Binutils and Clib2 we post there:

https://github.com/sba1/adtools/issues

Only with closesourced newlib we post it anywhere and then someone from beta-test ppls put them to os4's bugzilla

Go to top
Re: No std::to_string(float) in GCC 11
Not too shy to talk
Not too shy to talk


See User information
How can I become a beta tester? Really so that I can report on bugzilla.

Go to top
Re: No std::to_string(float) in GCC 11
Home away from home
Home away from home


See User information
@rjd324
Quote:

How can I become a beta tester? Really so that I can report on bugzilla.


if it was that easy when one want to report one or another bug and they let you join in beta-team because of that.

Hyperion full of betatesters already (and always was) and there even no managment anymore as far as i can tell. You may probabaly try to write to Ben but don't hold your hope there. it was always a big pain to join in.

Go to top
Re: No std::to_string(float) in GCC 11
Site Builder
Site Builder


See User information
@rjd324
As much as I know there is no opening right now for beta testers. If there is something that doesn't work with newlib I would suggest contacting kas1e or me and we will bring that to developers' attention.

We will only need a good description of the problem and an example code that make the issue reproducable.

Go to top
Re: No std::to_string(float) in GCC 11
Amigans Defender
Amigans Defender


See User information
Repository is now visible

https://github.com/afxgroup/clib2

Go to top
Re: No std::to_string(float) in GCC 11
Just popping in
Just popping in


See User information
@afxgroup

I am pretty excited about the shared library support. Question has anyone build cross compiler with shared support for C++?

Regards
Doug

Go to top
Re: No std::to_string(float) in GCC 11
Amigans Defender
Amigans Defender


See User information
me :)

You have to replace gcc/repo/gcc/config/rs6000/amigaos.h with this file:

www.amigasoft.net/temp/amigaos.h

Or use specs file included in library
However I suggest to recompile the entire gcc

Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project