libc++

Osx Lion: Xcode 4.1 how do I setup a c++0x project

梦想的初衷 提交于 2019-12-18 12:35:36
问题 I know there have been other questions like that but (i.e. Can I use C++11 with Xcode?) but mostly related to older versions of Osx or xcode so they don't really seem to be the right solution to go on Osx Lion and xcode 4.1. What are the requirements on osx Lion to use c++0x features? I think i'd have to set LLVM 3.0 as the compiler somehow using the new libc++ as the standard library. Is there a default way to get LLVM 3.0 to work on lion? Edit : Okay it seems its just a matter of time till

Does std::map require the comparator's operator() to be const?

落花浮王杯 提交于 2019-12-18 05:40:20
问题 The following code fails to compile with XCode 4.5's clang++ when using libc++ on OS X 10.8: #include <map> #include <string> class Foo { public: explicit Foo(int val_) : val(val_) {} int val; }; struct FooComparator { bool operator()(const Foo& left, const Foo& right) { return left.val < right.val; } }; int main(int argc, char* argv[]) { std::map<Foo, std::string, FooComparator> m; Foo f(4); m[f] = std::string("four"); return 0; } The error: broken.cpp:11:8: note: candidate function not

How do I get back c++0x/c++11 support for Mac OS X 10.6 deployment using Xcode 4.6.2 thru 7.1.1

谁说胖子不能爱 提交于 2019-12-17 22:43:57
问题 I heavily use the c++0x/c++11 features in my project, particularly code blocks and shared pointers. When I upgraded my OS to 10.8 Mountain Lion (Edit: From 10.7), I was forced to upgrade Xcode. In upgrading Xcode, I lost the ability to compile my c++ project for deployment on 10.6 systems as I get the following error. clang: error: invalid deployment target for -stdlib=libc++ (requires Mac OS X 10.7 or later) It appears that Apple is trying to force people to upgrade by not allowing

Discrepancy between istream's operator>> (double& val) between libc++ and libstdc++

对着背影说爱祢 提交于 2019-12-17 22:01:08
问题 With my recent upgrade to Mac OS X 10.9 the default standard C++ library changed from libstdc++ to libc++. Since then I observe unexpected behaviour of the stringstream operator>>(double) documented in the code example below. In summary the libc++ seems to have problems with extracting double values from stringstreams when the double value is followed by a letter. I already checked the standard (2003) but I can't find any specific information if extraction should work in this case or not. So

libc++ - stop std renaming to std::__1?

十年热恋 提交于 2019-12-17 20:05:43
问题 After substantial effort getting clang and libc++ to compile, run, integrate with NetBeans, and even cross-compile to a 32-bit machine, I thought I had it all figured out! So I go to use some features that libstdc++ didn't have (the entire reason for turning my dev environment upside down), and discover... I can't actually do that. libc++ is installed, it works, and the compiled program (when it works) does require it. However, the compiler still tries to use libstdc++ versions at every

Where does the __1 symbol come from when using LLVM's libc++?

前提是你 提交于 2019-12-17 11:51:30
问题 I see a fair amount of questions like Apple Mach-O Linker (Id) Error and Undefined symbols in cryptopp at IOS 64-bit project. The problem is usually described as: Undefined symbols for architecture i386: "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from: cv::gpu::error(char const*, char const*, int, char const*) in opencv2(gpumat.o) The problem often reduces to mixing/matching -stdlib=libc++ (LLVM C++ runtime) and -stdlib=libstdc++ (GNU C++ runtime). The

Why does libc++'s implementation of std::string take up 3x memory as libstdc++?

久未见 提交于 2019-12-17 07:26:21
问题 Consider the following test program: #include <iostream> #include <string> #include <vector> int main() { std::cout << sizeof(std::string("hi")) << " "; std::string a[10]; std::cout << sizeof(a) << " "; std::vector<std::string> v(10); std::cout << sizeof(v) + sizeof(std::string) * v.capacity() << "\n"; } Output for libstdc++ and libc++ respectively are: 8 80 104 24 240 264 As you can see, libc++ takes 3 times as much memory for a simple program. How does the implementation differ that causes

Clang++ -fmodules errors using types after #include <cstdint>

萝らか妹 提交于 2019-12-13 13:16:49
问题 The following simple test case file is giving me a compile-time error with the tip of 'master' from Clang's github mirror, when compiled with -fmodules , using the command shown below. I'm wondering if this is a bug with the new experimental Module feature for Clang -- maybe a problem with the implementation of module maps for the standard library -- or if there's something I'm doing wrong. The error still appears if I add -fbuiltin-module-map to the command. Interestingly, the error no

Convert std::filebuf(FILE*) to use libc++

独自空忆成欢 提交于 2019-12-13 05:12:25
问题 I have some existing code that I am trying to compile using clang 3.3 and libc++ from llvm.org. A simple step to retrieve the result of another command. It appears that std::filebuf doesn't offer a FILE* constructor any more and all the ideas that I have tried to replace the code have all failed to open the command, that is fb.is_open() always returns false. From what I can find I would have to use something like fb.open(cppcommand.c_str(), std::ios::in); instead of popen. The essential parts

C++ 11 threads with clang

此生再无相见时 提交于 2019-12-12 10:48:17
问题 I wanted to learn use of C++11 threads to speed up compilation of my language (yes I'm building a compiler :x). The first sample I tried threw several errors with clang (3.3 SVN). It compiled fine under GCC (4.6.3). I downloaded clang and libc++ from llvm.org's SVN. clang was compiled with GCC (4.6.3) and libc++ was compiled with clang. Both makefiles were generated with CMake. For clang I followed this guide: http://llvm.org/docs/GettingStarted.html#checkout For libc++ I followed this guide: