g++

Compiling C++ code using __float128

妖精的绣舞 提交于 2019-12-12 11:47:44
问题 I'm trying to use __float128 in my C++ program. However I'm in trouble with compiling it. Here is simple c++ code (test.cc): #include <iostream> #include <quadmath.h> using namespace std; int main(){ __float128 r=0.0q; __float128 exp_d = expq(12.45q); cout << "r=" << (double)r << endl; cout << "exp_d=" << (double)exp_d << endl; } And I compile this code with g++ test.cc -lquadmath -std=c++11 which comes with following error error:unable to find numeric literal operator 'operateor"" q' How can

Suppress delete-non-virtual-dtor warning when using a protected non-virtual destructor

﹥>﹥吖頭↗ 提交于 2019-12-12 10:57:16
问题 I have a pure abstract interface class, and a derived class which implements the interface. struct Foo { virtual void doStuff() = 0; }; struct Bar : Foo { void doStuff() override { } }; My interface class doesn't have a virtual destructor . Attempting to destruct a derived instance using a base class pointer is obviously therefore undefined behaviour int main() { Foo* f = new Bar; f->doStuff(); delete f; } Luckily my compiler is clever enough to catch this (with -Werror ) main.cc:15:9: error:

Remove note of GCC ABI change

末鹿安然 提交于 2019-12-12 10:45:49
问题 When I compile my program with GCC 4.7 I get the following note: /usr/include/c++/4.7/backward/binders.h:167:5: note: the ABI of passing structure with complex float member has changed in GCC 4.4 here Is there any way to get rid of it? I tried to google it, but all I find is the GCC source code line that prints the note string. 回答1: Pass the option -Wno-psabi to GCC. 回答2: I was getting the same message: /usr/include/c++/4.8.3/bits/stl_pair.h:276:5: note: the ABI of passing structure with

“has_trivial_destructor” defined instead of “is_trivially_destructible”

穿精又带淫゛_ 提交于 2019-12-12 10:42:42
问题 During the refinement process of the C++11 standard, it seems that is_trivially_destructible was considered a better/more-consistent name than has_trivial_destructor. This is a relatively recent development, as my g++ 4.7.1 still uses the old name, and it's been fixed to be compliant with the standard as of 4.8: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52702 I've been lazily using an #if which favors the compiler I'm on: #if TRIVIAL_DESTRUCTOR_TYPE_TRAIT_MATCHES_STANDARD template<class T>

g++ not working on Windows command prompt. Cygwin installed

妖精的绣舞 提交于 2019-12-12 09:42:41
问题 I have installed Eclipse and CDT (to use C/C++ in eclipse CDT is needed), as well as installing Cygwin so that I can compile my files. In environment variables I've set Path to include the following: "C:\cygwin\bin;" g++, make and GDC are all installed via Cygwin. I made sure of this by searching for them in the bin folder - they're all there. If I enter "make" into the windows command prompt, this appears: make: *** No targets specified and no makefile found. Stop. If I enter "g++" or "gdc"

“no viable conversion” with lemon for clang but valid for g++

白昼怎懂夜的黑 提交于 2019-12-12 09:08:55
问题 Currently, I try to incorporate lemon library in our project. Most developers are on Windows, they compile with MSVC, but I am in charge (for this part) to compile with gcc and clang. I came across an error with clang that gcc does not reproduce and I managed to reduce the code: #include <lemon/dfs.h> int main() { lemon::ListDigraph g{}; lemon::ListDigraph::Node node = g.nodeFromId(42); lemon::Dfs<lemon::ListDigraph> dfs{g}; lemon::SimplePath<lemon::ListDigraph> path = dfs.path(node); return

undefined reference to std::basic_string

那年仲夏 提交于 2019-12-12 08:57:09
问题 I'm compiling my project and seeing link problem $ g++ -Wl,-z,now -Wl,-z,relro -pthread -Wl,-z,noexecstack -fPIC -Wl,--threads -Wl,--thread-count=4 -B../../third_party/gold -L. -Wl,-uIsHeapProfilerRunning,-uProfilerStart -Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi -Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl -Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u

Is it OK to specify a duplicate C++ class scope? [duplicate]

拜拜、爱过 提交于 2019-12-12 08:27:27
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Why are redundant scope qualifications supported by the compiler, and is it legal? I wouldn't expect this to compile but it does. Could this be a compiler bug, or does it have some correct meaning? $ g++ -c scopes.cpp $ cat scopes.cpp class Log { public: Log() { } static void fn() { } }; void test() { Log::Log::Log::Log::Log::Log::fn(); } $ g++ --version g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3 回答1: Yes, it's legal

Hiding instantiated templates in shared library created with g++

十年热恋 提交于 2019-12-12 08:24:11
问题 I have a file that contains the following: #include <map> class A {}; void doSomething() { std::map<int, A> m; } When compiled into a shared library with g++, the library contains dynamic symbols for all the methods of std::map<int, A> . Since A is private to this file, there is no possibility that std::map will be instantiated in any other shared library with the same parameters, so I'd like to make the template instantiation hidden (for some of the reasons described in this document). I

How to suppress warnings for 'void*' to 'foo*' conversions (reduced from errors by -fpermissive)

流过昼夜 提交于 2019-12-12 07:49:05
问题 I'm trying to compile some c code with g++ (yes, on purpose). I'm getting errors like (for example): error: invalid conversion from 'void*' to 'unsigned char*' [-fpermissive] adding -fpermissive to the compilation options gets me: error: invalid conversion from 'void*' to 'unsigned char*' [-Werror=permissive] which seems to be a error because of -Werror , however adding -Wno-error=permissive -Wno-permissive results in: error: -Werror=permissive: no option -Wpermissive error: unrecognized