libc++

std::cerr on linux with clang++ and libc++ causes SIGABRT

对着背影说爱祢 提交于 2019-12-05 20:11:09
I'm trying to get a simple program running on Ubuntu 12.04 x64 compiled with clang++ 3.3 libc++ libc++abi . Program: #include <iostream> int main(int argc, char **argv) { try { std::cerr << "Test cerr \n"; } catch (...) { std::cout << "catch exception"; } return 0; } Writing to std::cerr prints the message, but results in SIGABRT. However, writing to std::cout works fine. Here the ldd output of the executable: $ldd cerr_test linux-vdso.so.1 => (0x00007fffce5ff000) libc++abi.so.1 => /usr/local/lib/libc++abi.so.1 (0x00007fa4079fd000) libc++.so.1 => /usr/local/lib/libc++.so.1 (0x00007fa407759000)

Taking pointer to member std::string::size fails to link with libc++ but works with libstdc++

跟風遠走 提交于 2019-12-05 19:51:40
I'm on a project where I need to use libc++. I'm come up with the following problem: When I try to compile the following code: #include <string> int main() { std::string::size_type (std::string::*function)() const = &std::string::size; return 0; } I get the following error: ld: symbol(s) not found for architecture x86_64 If I use the libstdc++ instead of libc++ I get no errors so the issue should to be related with libc++. Full output below: clang++ --stdlib=libc++ -v main.cpp Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.1.0 Thread model: posix "

How I do compile a application against a static library compiled with libc++ in xcode/clang/macos?

给你一囗甜甜゛ 提交于 2019-12-05 19:29:30
When I try to compile a test console application to test some functionality on a static library on the same workspace, i run into problems in the linking stage of the binary, it only happen when I choose to use libc++ standard library. The missing symbols error is the follow : Undefined symbols for architecture x86_64: "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::empty() const", referenced from: libtorrent::torrent::replace_trackers(std::__1::vector<libtorrent::announce_entry, std::__1::allocator<libtorrent::announce_entry> > const&) in

How to use experimental parallel STL in C++1z?

痴心易碎 提交于 2019-12-05 13:45:25
I want to try parallel STL of C++17. However, I can't find experimental/execution_policy in libc++. How can I try this? I'm trying http://en.cppreference.com/w/cpp/experimental/reduce , which says I should include these files, but I cannot find execution_policy. #include <experimental/execution_policy> After I install libc++ (I followed http://libcxx.llvm.org/docs/BuildingLibcxx.html ), I tried the following commands, but in vain. $ clang++-3.5 -std=c++1z test.cpp -lc++experimental test.cpp:5:10: fatal error: 'experimental/execution_policy' file not found #include <experimental/execution

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

半城伤御伤魂 提交于 2019-12-05 10:51:19
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 << "testfile does not exist" << endl; return -1; } while ( 1 ) { file->clear(); // remove end of file evil

Customising std::shared_ptr or boost::shared_ptr to throw an exception on NULL dereference

こ雲淡風輕ζ 提交于 2019-12-05 06:59:00
I have a few projects that use boost::shared_ptr or std::shared_ptr extensively (I can convert to either implementation soon enough, if there is a good answer to this question for one, but not the other). The Boost implementation uses Boost.Assert to avoid returning in the case of encountering an empty (NULL) pointer in operator* or operator-> at runtime; while the libc++ implementation seems to lack any check. While of course the validity of a shared_ptr should be checked before use, a large, mixed-paradigm codebase leads me to want to try an exception-throwing variation; as most of the code

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

北城余情 提交于 2019-12-05 04:53:48
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? Howard Hinnant See this answer for why libc++ chose forward order. As for why libstdc++ chose reverse order, that is probably because that's how it was demonstrated in the variadics template

zipalign: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory

旧时模样 提交于 2019-12-05 03:55:14
问题 I am trying to build android app. When I run the zip align tool to optimize the APK, I get this error message: zipalign: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory I tried to install libc++ sudo aptitude install libc++ it says: Couldn't find package "libc+". Snapshot of my terminal 回答1: If your system is 64-bits, there should be a folder lib64 on the path of [android-path]/build-tools/[version]/ The files in lib64 are [ec2-user

istream eof discrepancy between libc++ and libstdc++

空扰寡人 提交于 2019-12-05 03:10:30
The following (toy) program returns different things when linked against libstdc++ and libc++. Is this a bug in libc++ or do I not understand how istream eof() works? I have tried running it using g++ on linux and mac os x and clang on mac os x, with and without -std=c++0x. It was my impression that eof() does not return true until an attempt to read (by get() or something else) actually fails. This is how libstdc++ behaves, but not how libc++ behaves. #include <iostream> #include <sstream> int main() { std::stringstream s; s << "a"; std::cout << "EOF? " << (s.eof() ? "T" : "F") << std::endl;

Checking for C++11 library features

空扰寡人 提交于 2019-12-05 02:36:38
What is a good way of checking for the presence of specific C++11 features of the standard library . For compiler features I just went by the way of checking the compiler version for the (IMHO) major compilers ( VC++ , gcc , clang at the moment, maybe Intel ) Although this is not the best and most flexible approach, I don't know of anything better yet, except for clang which has the really nice __has_feature macros. But it's even worse for library features, which are not coupled that rigidly to the compiler. At the moment I want to use the same approach of checking the compiler version for VC+