clang 3.4.1没有名为' to_string'在命名空间' std'

时间:2014-08-03 15:22:43

标签: windows c++11 netbeans mingw clang

我一直在努力让c ++ 11,llvm / clang和netbeans在Windows上工作。我几乎被困在这里了。我无法通过clang来查看to_string方法。在深入了解basic_string头文件后,我注意到在定义to_string之前有一些#ifdefs

#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
     && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))

在Netbeans中,我可以控制 - 单击_GLIBCXX_HAVE_BROKEN_VSWPRINTF并注意其定义为1并且控制单击对__cplusplus和_GLIBCXX_USE_C99不起作用,因此我假设它们未定义。

有谁知道如何解决这个问题?

此处还有构建信息&&源代码,如果它有帮助。

clang++ -v   -c -g -w -I../SFML/include -I../SFML/src -I../boostInclude -I/C\MinGW\lib\gcc\mingw32\4.8.1\include -I/C\MinGW\lib\gcc\mingw32\4.8.1\include-fixed -std=c++11 -MMD -MP -MF "build/Debug/CLang-Windows/System/SPString.o.d" -o build/Debug/CLang-Windows/System/SPString.o System/SPString.cpp
clang version 3.4.1 (207424)
Target: i686-pc-mingw32
Thread model: posix
Selected GCC installation: 
 "c:\Program Files (x86)\LLVM\bin\clang++.exe" -cc1 -triple i686-pc-mingw32 -S -disable-free -main-file-name SPString.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-cpu pentium4 -v -g -coverage-file "C:\\Users\\IZACK_~1\\AppData\\Local\\Temp\\SPString-929e91.s" -resource-dir "c:\\Program Files (x86)\\LLVM\\bin\\..\\lib\\clang\\3.4.1" -dependency-file build/Debug/CLang-Windows/System/SPString.o.d -MT build/Debug/CLang-Windows/System/SPString.o -MP -I ../SFML/include -I ../SFML/src -I ../boostInclude -I C:/MinGW/msys/1.0/CMinGWlibgccmingw324.8.1include -I C:/MinGW/msys/1.0/CMinGWlibgccmingw324.8.1include-fixed -w -std=c++11 -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir "C:\\SynapseCpp\\SynapseCore" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-slp -o "C:\\Users\\IZACK_~1\\AppData\\Local\\Temp\\SPString-929e91.s" -x c++ System/SPString.cpp
clang -cc1 version 3.4.1 based upon LLVM 3.4.1-rc2 default target i686-pc-mingw32
ignoring nonexistent directory "C:/MinGW/msys/1.0/CMinGWlibgccmingw324.8.1include"
... bunch of irrelevant 'nonexistent directory' ...
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 ../SFML/include
 ../SFML/src
 ../boostInclude
 c:/MinGW/lib/gcc/mingw32/4.8.1/include/c++
 c:/MinGW/lib/gcc/mingw32/4.8.1/include/c++/mingw32
 c:/MinGW/lib/gcc/mingw32/4.8.1/include/c++/backward
 c:\Program Files (x86)\LLVM\bin\..\lib\clang\3.4.1\include
 c:\Program Files (x86)\LLVM\bin\..\lib\clang\3.4.1\../../../include
 /mingw/include
End of search list.
System/SPString.cpp:14:20: error: no member named 'to_string' in namespace 'std'
    string += std::to_string(right);
              ~~~~~^
System/SPString.cpp:21:20: error: no member named 'to_string' in namespace 'std'
    string += std::to_string(right);
              ~~~~~^
2 errors generated.

这是源代码:

#include "SPString.h"
#include <string>

sf::String& operator +=(const sf::String& left, int right)
{
    sf::String string = left;
    string += std::to_string(right);
    return string;
}

sf::String& operator +(const sf::String& left, int right)
{
    sf::String string = left;
    string += std::to_string(right);

    return string;
}

1 个答案:

答案 0 :(得分:0)

我对你的sf课程知之甚少,但这里有一个可行的解决方法:

#include "SPString.h"
#include <string>
#include <sstream>

sf::String& operator +=(const sf::String& left, int right)
{
     std::stringstream stream;
     stream << right;

     sf::String string = left;
     string += stream.str(); 
     return string;
}