libstdc++

C++11 standard libraries in libstdc++ on Mac

点点圈 提交于 2019-12-23 02:02:05
问题 In a Xcode project which I currently work on, I am using C++11 with Apple LLVM 4.2 (clang) compiler, and using libstdc++ as my standard library, because I am using a library (NTL) which was not compiled with libc++ and so I must use libstdc++. When writing the following code: #include <regex> int main() { return 0; } It doesn't compile, by saying: 'regex' file not found And so I can't use any C++11 library with my libstdc++ (Tried <mutex> , <thread> aswell). Another I tried to take is to

clang 3.3/Xcode & libc++: std::getline does not read data after calling ifstream::clear()

≯℡__Kan透↙ 提交于 2019-12-22 07:06:40
问题 The following program demonstrates an inconsistency in std::getline behavior between libc++ and libstdc++ (using clang3.3). The program opens the file testfile, reads it until eof, then clears the error bits using ifstream::clear and tries to read from the same filehandle again to see if new data was appended to the file. #include <fstream> #include <iostream> #include <unistd.h> using namespace std; int main() { ifstream* file = new ifstream("testfile"); if ( ! file->is_open() ) { cout <<

C++: How to force libc declarations into std::?

社会主义新天地 提交于 2019-12-22 06:53:54
问题 So, I find myself in the need of libc in my C++ program. However, I do not like the idea of sprinkling it all over the global namespace. Ideally, I'd like to force the entirety of libc into the std:: namespace so I'd have to do std::memcpy rather than memcpy . Is this possible? And how? I'm willing to use compiler-specific macros if needed (I target only MS VC++ 10.0 and GCC 4.6). Edit: I do literally mean 'force the declarations into std' - so that they are uncallable without the std::

C++: How to force libc declarations into std::?

北战南征 提交于 2019-12-22 06:52:04
问题 So, I find myself in the need of libc in my C++ program. However, I do not like the idea of sprinkling it all over the global namespace. Ideally, I'd like to force the entirety of libc into the std:: namespace so I'd have to do std::memcpy rather than memcpy . Is this possible? And how? I'm willing to use compiler-specific macros if needed (I target only MS VC++ 10.0 and GCC 4.6). Edit: I do literally mean 'force the declarations into std' - so that they are uncallable without the std::

“the procedure entry point _ZNSt8_detail15_List_node_base7_M_hookEPS0_ could not be located in the dynamic link library libstdc -6.dll.”

不打扰是莪最后的温柔 提交于 2019-12-22 06:35:22
问题 have a small problem. I have c++ code, it's linking to some libraries. I have previously (original)exe from the source code and that runs perfectly on first machine. And there is second machine, where I work on the source code, change it, etc. On the second machine, the build of that source code works fine, bud when I copy the second.exe and try tu run it on the first machine it displays error message "the procedure entry point _ZNSt8_detail15_List_node_base7_M_hookEPS0_ could not be located

c++11 STL's binomial_distribution extremely slow

时光怂恿深爱的人放手 提交于 2019-12-22 06:32:04
问题 I am generating binomially distributed random numbers using STL's 'random'. It becomes extremely slow when the range is big. For the range 40 it takes 12 seconds to generate 100 numbers. For bigger ranges time increases dramatically (I need ranges around 10000). It does not seem to depend on the probability parameter. I am using g++ 4.5.0. #include <iostream> #include <random> using namespace std; vector<int> v; default_random_engine gen(123); binomial_distribution<int> rbin(40,0.7); int main

std::regex and dual ABI

橙三吉。 提交于 2019-12-22 05:13:57
问题 Today I have found an interesting case of the dual libstdc++ ABI affecting compatibility of libraries. Long story short, I have two libraries that both use std::regex internally. One is built with the CXX11 ABI and one is not. When these two libraries are linked together in one executable, it crashes on startup (before main is entered). The libraries are unrelated and do not expose interfaces that mention any std:: types. I thought such libraries should be immune to dual ABI issues.

Getting GCC in C++11 mode to work on FreeBSD

六月ゝ 毕业季﹏ 提交于 2019-12-22 05:11:34
问题 How do I get a working GCC-based C++11 setup on FreeBSD 10? It seems that the standard library that comes with recent GCC versions on FreeBSD is broken. I've installed the port gcc49 and then try to compile this: #include <string> int main() { auto str = std::to_string(42); str = std::to_string(42ull); str = std::to_string(4.2); str.clear(); return 0; } This gives me an error: g++49 -v -std=c++11 foo.cc Using built-in specs. COLLECT_GCC=g++49 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc49/gcc

Clang reject type_info as incomplete although <typeinfo> is included

这一生的挚爱 提交于 2019-12-22 05:09:38
问题 I'm lost as to why Clang rejects the following code: #include <typeinfo> #include <exception> const char* get_name( const std::exception_ptr eptr ) { return eptr.__cxa_exception_type()->name(); } int main() {} It OK with GCC, but Clang complains about type_info being an incomplete type: $ g++-4.7 -std=c++0x -O3 -Wall -Wextra t.cc -o t $ clang++-3.2 -std=c++0x -O3 -Wall -Wextra t.cc -o t t.cc:6:37: error: member access into incomplete type 'const class type_info' return eptr.__cxa_exception

Why does libstdc++ store std::tuple elements in reverse order?

我的未来我决定 提交于 2019-12-22 04:47:09
问题 According to http://flamingdangerzone.com/cxx11/2012/07/06/optimal-tuple-i.html, with regards to std::tuple... libstdc++ always places the members in reverse order, and libc++ always places the members in the order given Assuming that's true, is there a reason (historical or otherwise) why libstdc++ uses reverse order? Bonus: Has either implementation ever changed its std::tuple ordering for any reason? 回答1: See this answer for why libc++ chose forward order. As for why libstdc++ chose