gcc4.7

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

瘦欲@ 提交于 2020-01-12 07:35:09
问题 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

gcc 4.7.3 and gdb 7.6 on Mac - strange stepping problems

妖精的绣舞 提交于 2020-01-01 09:42:20
问题 I recently installed GCC 4.7.3 and GDB 7.6 on my OS X 10.7 system via MacPorts to be able to compile C++11 code. I cannot use Apple's selfmade clang++ and gdb since it doesn't allow me to debug standard template library code properly (for example, if I dereference a list iterator, the program crashes). Now, with the new GCC / GDB combination I have some weird problems with stepping into functions. Take this minimal example: #include <stdio.h> class A { public: virtual void testMethod() {

gcc 4.7.3 and gdb 7.6 on Mac - strange stepping problems

陌路散爱 提交于 2020-01-01 09:42:04
问题 I recently installed GCC 4.7.3 and GDB 7.6 on my OS X 10.7 system via MacPorts to be able to compile C++11 code. I cannot use Apple's selfmade clang++ and gdb since it doesn't allow me to debug standard template library code properly (for example, if I dereference a list iterator, the program crashes). Now, with the new GCC / GDB combination I have some weird problems with stepping into functions. Take this minimal example: #include <stdio.h> class A { public: virtual void testMethod() {

Issues of running C++11 executable compiled with gcc 4.7 on a computer with an older gcc / glibc / libstdc++

旧城冷巷雨未停 提交于 2019-12-23 03:22:33
问题 I am a newbie to C++ compilation in production environment I wonder if there are any issues in running a C++11 executable compiled with gcc4.7 ( on debian 6 ) on a computer with an older gcc version, an older glibc / libstdc++. Thanks EDIT : I want to add more details to my question ( maybe it's better to open a new question ? ) I need to compile a legacy C++ code with new libs in C++11 on debian 7 ( for gcc 4.7 ) and run the exe on debian 6 on fedora 18 ( for gcc 4.7 ) and run the exe on

Possible to access private types in base classes via template indirection

不羁岁月 提交于 2019-12-22 09:05:37
问题 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

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

微笑、不失礼 提交于 2019-12-22 04:35:09
问题 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

gcc c++11 limits for user defined constants and template parameter packs

☆樱花仙子☆ 提交于 2019-12-22 03:39:49
问题 I've been playing with user defined constants in gcc 4.7.2 and ran into some sort of size limiting factors which I do not quite understand. The idea was to define a constexpr operator "" for fixed point decimal type. I want to avoid casting from double but rather parse mantissa and exponent at compilation time using variadic templates. The mantissa parsing proved a bit tricky. When I enable any of the 3 disabled lines at the bottom of the code below, gcc falls into infinite loop and hangs

(Optimization?) Bug regarding GCC std::thread

别来无恙 提交于 2019-12-22 01:53:04
问题 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

Using unique_ptr to control a file descriptor

与世无争的帅哥 提交于 2019-12-17 19:23:02
问题 In theory, I should be able to use a custom pointer type and deleter in order to have unique_ptr manage an object that is not a pointer. I tried the following code: #ifndef UNIQUE_FD_H #define UNIQUE_FD_H #include <memory> #include <unistd.h> struct unique_fd_deleter { typedef int pointer; // Internal type is a pointer void operator()( int fd ) { close(fd); } }; typedef std::unique_ptr<int, unique_fd_deleter> unique_fd; #endif // UNIQUE_FD_H This doesn't work (gcc 4.7 with the -std=c++11

Why is scanf(“%hhu”, char*) overwriting other variables when they are local?

纵饮孤独 提交于 2019-12-17 13:26:23
问题 The title says it all. I'm using GCC 4.7.1 (bundled with CodeBlocks) and I faced a strange issue. Consider this: int main() { unsigned char a = 0, b = 0, c = 0; scanf("%hhu", &a); printf("a = %hhu, b = %hhu, c = %hhu\n", a, b, c); scanf("%hhu", &b); printf("a = %hhu, b = %hhu, c = %hhu\n", a, b, c); scanf("%hhu", &c); printf("a = %hhu, b = %hhu, c = %hhu\n", a, b, c); return 0; } For inputs 1, 2 and 3, this outputs a = 1, b = 0, c = 0 a = 0, b = 2, c = 0 a = 0, b = 0, c = 3 If I, however,