gcc4

Unexpected const reference behavior

允我心安 提交于 2019-12-08 19:14:19
问题 #include <iostream> class A { public: A(){ cerr << "A Constructor" << endl; } ~A(){ cerr << "A Destructor" << endl; } A(const A &o){ cerr << "A Copy" << endl; } A& operator=(const A &o){ cerr << "A Assignment" << endl; return *this; } }; class B : public A { public: B() : A() { cerr << "B Constructor" << endl; } ~B(){ cerr << "B Destructor" << endl; } private: B(const B &o) : A() { cerr << "B Copy" << endl; } B& operator=(const B &o){ cerr << "B Assignment" << endl; return *this; } }; int

gcc complains: variable-sized object may not be initialized

*爱你&永不变心* 提交于 2019-12-07 00:32:57
问题 I've looked at these and they do not answer my question: variable-sized object may not be initialized C compile error: "Variable-sized object may not be initialized" Error: Variable-sized object may not be initialized. But why? I am trying to write some fairly portable c code: int main () { const int foo=13; int bar[foo]={0}; return 0; } I get a variable-sized object may not be initialized error when compiling as c code using either: gcc 4.3.4 arm-linux-gnueabi-gcc 4.4.5 And if i compile it

Problem on Mac : “Can't find a register in class BREG while reloading asm”

江枫思渺然 提交于 2019-12-06 02:49:16
问题 I tried to port some code onto Mac OS X. The program uses the "ttmath" library, a header big-num header library. This library works fine on both windows and linux, but when I try to compile and run it on a Mac, the following error message always shows up : "can't find a register in class 'BREG' while reloading 'asm'". I found some documents say that this problem is due to the old version of GCC compiler (build 5488), but this message still shows up after I updated GCC. currently my GCC

gcc complains: variable-sized object may not be initialized

浪子不回头ぞ 提交于 2019-12-05 05:15:30
I've looked at these and they do not answer my question: variable-sized object may not be initialized C compile error: "Variable-sized object may not be initialized" Error: Variable-sized object may not be initialized. But why? I am trying to write some fairly portable c code: int main () { const int foo=13; int bar[foo]={0}; return 0; } I get a variable-sized object may not be initialized error when compiling as c code using either: gcc 4.3.4 arm-linux-gnueabi-gcc 4.4.5 And if i compile it as c in VS2008 i get a slightly different error C2057: expected constant expression I understand that

gcc 4.5 installation problem under ubuntu

夙愿已清 提交于 2019-12-04 11:41:55
I tried to install gcc 4.5 on ubuntu 10.04 but failed. Here is a compile error that I don't know how to solve. Is there anyone successfully install the latest gcc on ubuntu? Following is my steps and the error message, I'd like to know where is the problem.... Step1: download these files: gcc-core-4.5.0.tar.gz gcc-g++-4.5.0.tar.gz gmp-4.3.2.tar.bz2 mpc-0.8.1.tar.gz mpfr-2.4.2.tar.gz Step2: Unzip above files Step3: move gmp, mpc, mpfr to the gcc-4.5.0/ directory. mv gmp-4.3.2 gcc-4.5.0/gmp mv mpc-0.8.1 gcc-4.5.0/mpc mv mpfr-2.4.2 gcc-4.5.0/mpfr Step4: go to gcc-4.5.0 directory and do

What is a lifetime of a function return value?

五迷三道 提交于 2019-12-04 07:27:01
I read about the return values between function calls, and experimented with the following code snippet : /* file structaddr.c */ #include <stdio.h> #define MSIZE 10 struct simple { char c_str[MSIZE]; }; struct simple xprint(void) { struct simple ret = { "Morning !" }; return ret; } int main(void) { printf("Good %s\n", xprint().c_str); return 0; } The code is compiled without errors and warnings . Tested with GCC 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) and Visual C++ compilers . gcc -m32 -std=c99 -Wall -o test structaddr.c cl -W3 -Zi -GS -TC -Fetest structaddr.c Output : Good Morning ! I'm a little

Strange errors in intel's tbb

匆匆过客 提交于 2019-12-02 16:41:23
问题 I've build intel's tbb, and in my qt pro file I've included following line: INCLUDEPATH += "C:\\Downloads\\libraries\\tbb40_297oss\\include" but when I try to compile my project I'm getting an error: c:\Downloads\libraries\tbb40_297oss\include\tbb\internal\..\tbb_exception.h:340: error: 'exception_ptr' in namespace 'std' does not name a type Is there anything else I'm supposed to do? I cannot find any .lib files anywhere. 回答1: It is because you don't have _GLIBCXX_ATOMIC_BUILTINS_N (N = 1,2,4

How to Apply a GCC Patch

谁说胖子不能爱 提交于 2019-12-01 16:49:26
问题 I'm trying to apply this patch to GCC on MinGW to get it to compile GDC 2, but I don't know how. (I'm still new to the internals of GCC, and even to *nix tools in general.) I know there's the patch command but I can't figure out how to use it, and I don't even know if I have enough information for this. How do I apply the patch for GCC? 回答1: By default GNU Patch can be used by feeding a patch file to it from stdin (console input), e.g.: patch < file.patch There are many switches and options

Why do I get cc1plus: error: unrecognized command line option “-arch”?

偶尔善良 提交于 2019-11-30 08:13:32
问题 /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf /usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/cppapplication_1 mkdir -p build/Debug/GNU-MacOSX rm -f build/Debug/GNU-MacOSX/main.o.d g++ -arch i386 -c -g -MMD -MP -MF build/Debug/GNU-MacOSX/main.o.d -o build/Debug/GNU-MacOSX/main.o main.cpp cc1plus: error: unrecognized command line option "-arch" make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build

Why do I get cc1plus: error: unrecognized command line option “-arch”?

懵懂的女人 提交于 2019-11-29 06:14:34
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf /usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/cppapplication_1 mkdir -p build/Debug/GNU-MacOSX rm -f build/Debug/GNU-MacOSX/main.o.d g++ -arch i386 -c -g -MMD -MP -MF build/Debug/GNU-MacOSX/main.o.d -o build/Debug/GNU-MacOSX/main.o main.cpp cc1plus: error: unrecognized command line option "-arch" make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 311ms) simpatico$ g++ -v Using built-in specs.