gcc4.7

Possible to access private types in base classes via template indirection

懵懂的女人 提交于 2019-12-05 13:37:25
I'm trying to, at compile time, select a type to use depending on whether one is publicly available in a given scope. It's best to go straight to the code: #include <iostream> #include <type_traits> class Logger { std::string _p; public: Logger(std::string p): _p(p) { } void say(std::string message) { std::cout << _p << ' ' << message << std::endl; } }; struct Log { static Logger& log() { static Logger _def("Default: "); return _def; } }; // 1. template <typename P> struct use_logger { static std::size_t test(P*); static char test(...); static const bool value = sizeof(test(reinterpret_cast<P*

Does std::vector satisfy the container requirements for Boost.Interprocess allocators?

偶尔善良 提交于 2019-12-05 04:07:20
In boost::interprocess documentation it is said as requirement for containers to be stored in shared memory: STL containers may not assume that memory allocated with an allocator can be deallocated with other allocators of the same type. All allocators objects must compare equal only if memory allocated with one object can be deallocated with the other one, and this can only tested with operator==() at run-time. Containers' internal pointers should be of the type allocator::pointer and containers may not assume allocator::pointer is a raw pointer. All objects must be constructed-destroyed via

(Optimization?) Bug regarding GCC std::thread

点点圈 提交于 2019-12-04 23:32:10
While testing some functionality with std::thread , a friend encountered a problem with GCC and we thought it's worth asking if this is a GCC bug or perhaps there's something wrong with this code (the code prints (for example) "7 8 9 10 1 2 3", but we expect every integer in [1,10] to be printed): #include <algorithm> #include <iostream> #include <iterator> #include <thread> int main() { int arr[10]; std::iota(std::begin(arr), std::end(arr), 1); using itr_t = decltype(std::begin(arr)); // the function that will display each element auto f = [] (itr_t first, itr_t last) { while (first != last)

GCC: -static and -pie are incompatible for x86?

假装没事ソ 提交于 2019-12-03 13:05:17
I'm recompiling some executable for Android 5.0 as it requires executables to be PIE . I was able to recompile it for ARM with just adding some arguments while configuring (with standalone toolchain): export CFLAGS="-I/softdev/arm-libs/include -fPIE" export CPPLAGS="$CPPFLAGS -fPIE" export CXXLAGS="$CXXFLAGS -fPIE" export LDFLAGS="-L/softdev/arm-libs/lib -static -fPIE -pie" No error for ARM: configure:3406: arm-linux-androideabi-gcc -o conftest -I/softdev/arm-libs/include -fPIE -L/softdev/arm-libs/lib -static -fPIE -pie conftest.c >&5 configure:3410: $? = 0 But i was unable to do the same for

map::emplace() with a custom value type

两盒软妹~` 提交于 2019-12-03 10:47:42
I'm having trouble using map::emplace() . Can anyone help me figure out the right syntax to use? I am effectively trying to do the same thing as in this example . Here is my version: #include <map> using namespace std; class Foo { // private members public: Foo(int, char, char) /* :init(), members() */ { } // no default ctor, copy ctor, move ctor, or assignment Foo() = delete; Foo(const Foo&) = delete; Foo(Foo &&) = delete; Foo & operator=(const Foo &) = delete; Foo & operator=(Foo &&) = delete; }; int main() { map<int, Foo> mymap; mymap.emplace(5, 5, 'a', 'b'); return 0; } Under GCC 4.7 (with

Linker Error : gcc

狂风中的少年 提交于 2019-12-01 04:15:42
I am getting this error every time, while compiling programs, configuring and installing some things like binutils, textinfo, etc.. /usr/local/bin/ld: this linker was not configured to use sysroots collect2: error: ld returned 1 exit status I want to know clearly about this. When will will come and what is the actual problem, and also how to solve it? Try to use gcc with the following option: gcc --sysroot=/usr/local But, as the others told you in the comments, don't try to mess your system with critical packages such as the binutils , except if you know what you are doing. If you were

g++ 4.7 evaluates operator “” as sibling to macro expansion

久未见 提交于 2019-12-01 02:48:53
I'm moving some code over to GCC 4.7 (from 4.6) and ran into a few compiler errors and found the problem documented in the GCC 4.7 porting guide : User-defined literals and whitespace The C++ compiler in ISO C11 mode std={c++11,c++0x,gnu++11,gnu++0x} supports user defined literals, which are incompatible with some valid ISO C++03 code. In particular, whitespace is now needed after a string literal and before something that could be a valid user defined literal. Take the valid ISO C++03 code const char *p = "foobar"__TIME__; In C++03, the TIME macro expands to some string literal and is

Linker Error : gcc

社会主义新天地 提交于 2019-12-01 02:09:00
问题 I am getting this error every time, while compiling programs, configuring and installing some things like binutils, textinfo, etc.. /usr/local/bin/ld: this linker was not configured to use sysroots collect2: error: ld returned 1 exit status I want to know clearly about this. When will will come and what is the actual problem, and also how to solve it? 回答1: Try to use gcc with the following option: gcc --sysroot=/usr/local But, as the others told you in the comments, don't try to mess your

g++ 4.7 evaluates operator “” as sibling to macro expansion

痞子三分冷 提交于 2019-11-30 23:32:18
问题 I'm moving some code over to GCC 4.7 (from 4.6) and ran into a few compiler errors and found the problem documented in the GCC 4.7 porting guide: User-defined literals and whitespace The C++ compiler in ISO C11 mode std={c++11,c++0x,gnu++11,gnu++0x} supports user defined literals, which are incompatible with some valid ISO C++03 code. In particular, whitespace is now needed after a string literal and before something that could be a valid user defined literal. Take the valid ISO C++03 code

How to disable narrowing conversion warnings?

主宰稳场 提交于 2019-11-29 13:19:18
I use -Wall and updating to new gcc I have got a lot of warning: narrowing conversion . I want to disable them, but leave all other warnings untouched (ideally). I can find nothing about narrowing in http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html How to disable narrowing conversion warnings? Is it possible at all? P.S. I need to Disable warnings, not fix them in the source code. Blind -Wno-conversion doesn't help. Stryck As gx_ said, adding -Wno-narrowing to your command line should ignore those errors. Encountered this myself when upgrading to C++0x. 来源: https://stackoverflow.com