libstdc++

Spurious copies in c++03 libstdc++ vs c++11

老子叫甜甜 提交于 2019-12-04 03:20:44
问题 Consider this code: #include <iostream> #include <string> #include <map> using namespace std; class Foo { public: Foo() : _x(0) { cout << "Default" << endl; } Foo(int a) : _x(a) { cout << "Param" << endl; } Foo(Foo const &foo) : _x(foo._x) { cout << "Copy" << endl; } Foo& operator=(Foo const &foo) { cout << "Assignment" << endl; _x = foo._x; return *this; } int get(void) { return _x; } private: int _x; }; int main(int argc, char *argv []) { std::map<int, Foo> foos; Foo a_foo(10); foos[100] =

Does the standard mandate enable_shared_from_this is to be inherited publicly? Why?

百般思念 提交于 2019-12-04 03:11:22
问题 It's common to inherit from enable_shared_from_this just to be able to return shared_ptr 's from member functions as the primary intention, with no intention of exposing enable_shared_from_this API in the derived class. Since to make use of enable_shared_from_this one must do so through public inheritance (does the standard mandates this? what's the rationale?), this can't be achieved and enable_shared_from_this API is forced into derived class public API. Inherenting enable_shared_from_this

g++ without libstdc++ - can it be done? - a very configurable lightweight libstdc++ where I can take stuff out easily would also do the trick

家住魔仙堡 提交于 2019-12-04 01:42:35
I'm trying something spooky here. I'm trying to write C++ programs, compiled with GNU's g++, but without a dependency on libstdc++ :) but it seems that I need that for even the most basic things need it. A libstdc++ with a configurable feature set would be acceptable. The command I use is g++ -nodefaultlibs -fno-rtti -fno-exceptions -lc Without libstdc++, I get: undefined reference to `operator delete(void*)' undefined reference to `operator new(unsigned int)' undefined reference to `vtable for __cxxabiv1::__class_type_info' undefined reference to `vtable for __cxxabiv1::__si_class_type_info'

`cosf`, `sinf`, etc. are not in `std` [duplicate]

我只是一个虾纸丫 提交于 2019-12-03 23:43:25
This question already has an answer here: std::expf and std::logf not recognized by gcc 7.2.0 4 answers Based on the discussion here, I have reported a bug to the Ubuntu developers. When compiling the following sample c++ program: #include <cmath> #include <stdio.h> int main() { printf("%f\n", std::cosf(0.0f)); } I get the following error message: error: ‘cosf’ is not a member of ‘std’ Including math.h and using the non-namespaced version works fine. What is going on? I am using g++ 8.3.0-6ubuntu1 on Ubuntu 19.04. I am building with g++ --std=c++17 test.cpp That version of the library (

Is the Java Native Interface (JNI) affected by C++ ABI compatibility issues?

烈酒焚心 提交于 2019-12-03 16:39:08
问题 Is the Java Native Interface (JNI) affected by C++ ABI compatibility issues? I am developing a Java application. I would like to use the Java Native Interface (JNI) to call functions in a C++ library. I have access to the code for the C++ library, and I can rebuild it however I may need to. (For example, I can statically link the C++ runtime.) I can require my users to have JRE 6 or greater, but I can't require them to have any particular C++ runtime. A coworker pointed me to this blog

Where is __dso_handle defined?

梦想的初衷 提交于 2019-12-03 16:25:01
问题 I have an unresolved symbol error when trying to compile my program which complains that it cannot find __dso_handle . Which library is this function usually defined in? Does the following result from nm on libstdc++.so.6 mean it contains that? I tried to link against it but the error still occurs. nm libstdc++.so.6 | grep dso 00000000002fc480 d __dso_handle 回答1: __dso_handle is a "guard" that is used to identify dynamic shared objects during global destruction. Realistically, you should stop

Compiling one shared library on Linux to target all distributions

杀马特。学长 韩版系。学妹 提交于 2019-12-03 15:21:12
We want to create one shared library (.so) to target all distributions, including old ones. The code is written in C++ and uses C++11 features, so the compiler must be at least gcc 4.7. We noticed that if we compile our code on a Linux machine with gcc 4.7.2 installed (e.g., Ubuntu 12.10) then the .so produced has “version 1 (GNU/Linux)” while on older os (e.g., CentOS 5.6) the version is “version 1 (SYSV)” – and libraries with the GNU/Linux newer version cannot be used on older os. So we tried the approach of installing gcc 4.7 on the CentOS 5.6 machine, compile our code with this compiler

OS X program runs on dev machine, crashing horribly on others

别说谁变了你拦得住时间么 提交于 2019-12-03 13:08:02
I have an OS X 10.6 Mac I'm using as my dev machine. The program I wrote works perfectly on the dev machine. However, when I tried to run it on an OS X 10.5 (not sure if that's relevant) test machine, it crashes on launch. This is the error I'm getting: Process: MyApp[25908] Path: /Applications/MyApp.app/Contents/MacOS/MyApp Identifier: MyApp Version: ??? (???) Code Type: X86 (Native) Parent Process: launchd [109] Interval Since Last Report: 17392106 sec Crashes Since Last Report: 735 Per-App Interval Since Last Report: 0 sec Per-App Crashes Since Last Report: 8 Date/Time: 2010-08-14 07:50:09

SIGFPE when accessing unordered_map

风格不统一 提交于 2019-12-03 12:53:12
I have an unordered_map<Block, int> with Block being a simple struct defined as follows: struct Block { size_t start; size_t end; bool operator==(const Block& b) const { return start == b.start && end == b.end; } }; namespace std { template<> struct hash<Block> { size_t operator()(const Block& b) const { return b.start; } }; } When trying to access the map, I do get the following error message in gdb (same for both g++ 4.7.1 as well as clang++ 3.1): Program received signal SIGFPE, Arithmetic exception. 0x0000000000401e0b in std::__detail::_Mod_range_hashing::operator() (this=0x7fffffffd8e0, _

GLIBCXX_3.4.21 not found on CentOS 7

末鹿安然 提交于 2019-12-03 12:53:02
I recently updated my gcc version on CentOS from 4.7 to 5.4, but now I am getting the following error when I compile my program /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found I found some solutions , but I am still not able to fix the issue. These are the paths I found with whereis gcc gcc: /usr/bin/gcc /usr/lib/gcc /usr/local/bin/gcc /usr/local/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz and used this libstdc package for CentOS. Try export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64 I didn't have sudo access to my CentOS machine, so I installed gcc