g++

Why does the order of passing parameters to g++ matter

江枫思渺然 提交于 2021-02-07 14:00:33
问题 Recently, I was trying to build an application, which uses some libraries, available in form of shared object files. I wasted lot of time in compiling the CPP code and it didn't work. Below is the command, previously I was trying to compile the code- g++ -I/opt/ros/indigo/include/ -I/usr/include/eigen3/ -L/opt/ros/indigo/lib/ -lorocos-kdl -lkdl_parser test.cpp -o test The above command always shows many undefined references errors. Just for the curiosity, I changed the order of parameters.

Why does this code not compile in g++

浪子不回头ぞ 提交于 2021-02-07 13:11:27
问题 sample code given below is not compiled in g++. but it's working on visual studio. is it possible to use Template member function inside template class in g++ class Impl { public: template<class I> void Foo(I* i) { } }; template<class C> class D { public: C c; void Bar() { int t = 0; c.Foo<int>(&t); } }; int main() { D<Impl> d; d.Bar(); return 0; } 回答1: Because the statement in question depends on a template parameter, the compiler is not allowed to introspect C until instantiation. You must

gcc string table overflow error during compilation

落花浮王杯 提交于 2021-02-07 12:55:44
问题 When I try to buld a large complex example (modified to be more complex in terms of templates instantiations) from the boost spirit Qi compiler_tutorial I get the following error message: debug\expression.o:-1: error: section .debug_frame$_ZNK5boost5proto3if_INS0_6detail7has_tagINS0_6tagns_3tag7greaterEEENS0_12reverse_foldINS0_1_ENS0_6_stateENS2_18reverse_fold_tree_IS6_NS_6spirit6detail18make_binary_helperINSC_13meta_compilerINSC_2qi6domainEE12meta_grammarEEEEEEESK_E4implIRNSG_4ruleINSC

How to get gdb tui assembly output to show instruction?

依然范特西╮ 提交于 2021-02-07 12:23:31
问题 I wanted to see the assembly output but found that in TUI, it would output function signature + offset: which is cool, except for the fact that I'm programming in C++ and the function signature is fully resolved so I get namespaces and template parameters which make the function sig 2 or more lines long. This gets truncated in the TUI of course so it doesn't even get to display the assembly instruction. Is there any way to shorten, change the prefix (perhaps to a file/line format) or not

Template argument deduction: which compiler is right here?

为君一笑 提交于 2021-02-07 12:17:29
问题 Consider the following code: template<int N> class Vector { }; #include <array> template<int N> void doWork(const Vector<N>&, const std::array<int,N>&) { } int main() { std::array<int,3> arr; Vector<3> vec; doWork(vec,arr); } Here Vector represents a class which is defined in a third-party library, and std::array is known to take its element count as std::size_t . I've tried compiling this with clang-3.6 and g++-5.1. Clang worked without any complaint, while g++ gives the following error:

Template argument deduction: which compiler is right here?

左心房为你撑大大i 提交于 2021-02-07 12:15:31
问题 Consider the following code: template<int N> class Vector { }; #include <array> template<int N> void doWork(const Vector<N>&, const std::array<int,N>&) { } int main() { std::array<int,3> arr; Vector<3> vec; doWork(vec,arr); } Here Vector represents a class which is defined in a third-party library, and std::array is known to take its element count as std::size_t . I've tried compiling this with clang-3.6 and g++-5.1. Clang worked without any complaint, while g++ gives the following error:

How to achieve vector swizzling in C++?

[亡魂溺海] 提交于 2021-02-07 11:38:31
问题 struct vec2 { union { struct { float x, y; }; struct { float r, g; }; struct { float s, t; }; }; vec2() {} vec2(float a, float b) : x(a), y(b) {} }; struct vec3 { union { struct { float x, y, z; }; struct { float r, g, b; }; struct { float s, t, p; }; // Here is the problem with g++. struct { vec2 xy; float z; }; struct { float x; vec2 yz; }; }; vec3() {} vec3(float a, float b, float c) : x(a), y(b), z(c) {} }; The code above compiles and works as expected in Visual Studio and so I can use it

linux g++ compiler redirect stderr and stdout creates empty file

China☆狼群 提交于 2021-02-07 06:54:15
问题 I am redirecting the g++ compiler output(both stderr and stdout) to a file on linux. But it is creating an empty file. I read in some other post that stdout is not flushed after every line. Thats ok, but what about stderr. In my case there are compilation errors running several screens. So, I am interested in stderr output. There is no stdout output created. g++ -c -I ~/cplusplus/boost_1_37_0/boost_1_37_0/ -I ~/cplusplus/niVxWorksDeliver/TEES/ Algorithms.cpp 2> output The above command

templated recursive data types

主宰稳场 提交于 2021-02-07 05:33:47
问题 I have a recursive data type like this: template<typename T> struct SomeType { std::map<T, SomeType<T>> mapping; }; SomeType<int> foo; This works fine, but replacing std::map with std::unordered_map results in a compile error due to an incomplete type. Am I (or gcc) making an error somewhere? or is this just part of the standard? I would also like to have the internal container determined by a template parameter (like std::stack and std::queue ), but I can't figure out a way to do it since

templated recursive data types

拈花ヽ惹草 提交于 2021-02-07 05:33:18
问题 I have a recursive data type like this: template<typename T> struct SomeType { std::map<T, SomeType<T>> mapping; }; SomeType<int> foo; This works fine, but replacing std::map with std::unordered_map results in a compile error due to an incomplete type. Am I (or gcc) making an error somewhere? or is this just part of the standard? I would also like to have the internal container determined by a template parameter (like std::stack and std::queue ), but I can't figure out a way to do it since