g++

g++ doesn't like template method chaining on template var?

﹥>﹥吖頭↗ 提交于 2019-12-19 08:14:55
问题 I'm trying to compile with g++ some code previously developed under Visual C++ 2008 Express Edition , and it looks like g++ won't let me call a template method on a reference returned by a method of a template variable. I was able to narrow the problem down to the following code: class Inner { public: template<typename T> T get() const { return static_cast<T>(value_); }; private: int value_; }; class Outer { public: Inner const& get_inner() { return inner_; }; private: Inner inner_; };

g++ doesn't like template method chaining on template var?

为君一笑 提交于 2019-12-19 08:14:04
问题 I'm trying to compile with g++ some code previously developed under Visual C++ 2008 Express Edition , and it looks like g++ won't let me call a template method on a reference returned by a method of a template variable. I was able to narrow the problem down to the following code: class Inner { public: template<typename T> T get() const { return static_cast<T>(value_); }; private: int value_; }; class Outer { public: Inner const& get_inner() { return inner_; }; private: Inner inner_; };

Can I ungarble GCC's RTTI names?

此生再无相见时 提交于 2019-12-19 07:23:44
问题 Using gcc, when I ask for an object/variable's type using typeid, I get a different result from the type_info::name method from what I'd expect to get on Windows. I Googled around a bit, and found out that RTTI names are implementation-specific. Problem is, I want to get a type's name as it would be returned on Windows. Is there an easy way to do this? 回答1: If it's what you're asking, there is no compiler switch that would make gcc behave like msvc regarding the name returned by type_info:

C++ Standard: Unexpected const_iterator in multiset

杀马特。学长 韩版系。学妹 提交于 2019-12-19 06:27:08
问题 I recently ran into an odd issue where I'd get a const_iterator instead of the expected iterator when iterating through a multiset. It turned out to be a non-issue for MSVC but g++ gave me an error: error: invalid initialization of reference of type 'myPtr&' from expression of type 'const boost::shared_ptr' Relevant code: typedef std::multiset<myPtr> myList; myList _mystuff; void tick(float dt) { for (myList::iterator i = _mystuff.begin(); i != _mystuff.end(); ++i) { myPtr &mine = *i; // g++

va_list has not been declared

人走茶凉 提交于 2019-12-19 05:13:05
问题 When compiling some working code on Fedora 11, I am getting this error: /usr/include/c++/4.4.1/cstdarg:56: error: ‘::va_list’ has not been declared I am using: [doriad@davedesktop VTK]$ g++ --version g++ (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2) Does anyone know what the problem could be? 回答1: I had the same error message and I solved including one of the next files #include <stdarg.h> or #include <cstdarg> 回答2: Bringing in the varadic macro set in g++ 4.4 has confusing and twisted semantics.

How to link with specific library ( g++; libstdc++.so.5 and libstdc++.so.6 )

╄→尐↘猪︶ㄣ 提交于 2019-12-19 03:49:17
问题 A simple question - is there any way to make the g++ linker to link with a specific libstdc++ library version? I didn't find anything useful in the man page of gcc / g++ , neither in other questions here. Here's the situation - my application uses a specific shared library, that's built with libstdc++.so.5 and I want to install and use it on RHEL5 . So, when I try to build the application on a RHEL5 machine, I got the warning: warning: libstdc++.so.5, needed by ..the_shared_library_.. may

Undefined symbol _main when trying to build shared library g++ / mac

女生的网名这么多〃 提交于 2019-12-19 03:37:10
问题 I am trying to build libdecodeqr on a mac. My c++ building and linking history is all on windows, so it's an exciting journey of discovery. I have finally got to the point where I want to create the linked library. The command I am running is: g++ -shared -o libdecodeqr.so.0.9.3 bitstream.o codedata.o container.o ecidecoder.o formatinfo.o galois.o imagereader.o libdecodeqr.o -L/opt/local/lib -arch i386 -lcxcore -lcv The result is: Undefined symbols: "_main", referenced from: start in crt1.10

C++: What GNU G++ parameters? [duplicate]

∥☆過路亽.° 提交于 2019-12-19 03:22:59
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Best compiler warning level for C/C++ compilers? GCC has thousands of options to add more warnings; I was hoping that -Wall -Wextra -pedantic included all the useful ones, but just now I met -Woverloaded-virtual which seems really nice to me. What other G++ parameters do you use or would you recommend? 回答1: Not quite the same category but I always compile with -Werror to flag warnings as errors. Very useful. To

address of register variable in C and C++

时光怂恿深爱的人放手 提交于 2019-12-19 03:18:12
问题 I know the concept of register variable and it's use cases but there are few questions in my mind based on what I have tried. I cannot access the address of a register variable in C though I can do it C++! Why? Is there any issue in accessing the addressing of a register variable? Suppose if I declare a string variable in C++ as register, then where will that variable be stored? What is the point in declaring the storage class of non-numeric data types such as 'string' in C++ to be register??

How to install g++ 4.4 on Ubuntu?

岁酱吖の 提交于 2019-12-19 03:12:22
问题 There is a Debian g++-4.4 package, but it's not Ubuntu. There are too many system-destroyed scary stories on the web. How can I install g++ 4.4 on Ubuntu? 回答1: Have a look at this URL. I installed gcc-4.4 (and g++-4.4) from there, which seem to be the most official group of hackers that actually put gcc-4.4 into an ubuntu .deb. Till now running without problems : https://launchpad.net/~ubuntu-toolchain/+archive/ppa Regards. 回答2: I recomend you install build-essential package that contains g++