gcc

Reusing Memory in C++

Just wondering is this kind of code recommended to increase performance? void functionCalledLotsofTimes() { static int *localarray = NULL; //size is a large constant > 10 000 if (localarray == NULL) localarray = new int[size]; //Algorithm goes here } I'm also curious how static variables are implemented by modern c++ c...

Problem with gcc tracker/make/fork/exec/wait.

This is a most singular problem, with many interdisciplinary ramifications. It focuses on this piece of code (file name mainpp.c): #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int status; if (fork()) { FILE *f=fopen("/tmp/gcc-trace","a"); fprintf(f,"----------------------------------...

Terminating because of 6 signal

Hi, I compiled and ran my code and got the following error: Terminating because of 6 signal What is signal 6 and what causes it? ...

-fomit-frame-pointer, is it safe to use it?

I've seen in many places that people often use the option -fomit-frame-pointer when compiling C / C++ code and I wonder, is the use of that option safe? What is it used for? Thank you very much, best regards. ...

Why doesn't my overloaded comma operator get called?

Hi, I'm trying to overload the comma operator with a non-friend non-member function like this: #include <iostream> using std::cout; using std::endl; class comma_op { int val; public: void operator,(const float &rhs) { cout << this->val << ", " << rhs << endl; } }; void operator,(const float &lhs, const comma_o...

Setting up a cross-compilation environment for a specific target platform

I'd like to set up a cross-compilation environment on a Ubuntu 9.10 box. From the documents I've read so far (these ones, for example) this involves compiling the toolchain of the target platforms. My question is: how do you determine the required version of each of the packages in the toolchain for a specific target platform? Is there ...

How to invoke C compiler under gcc

According to my memory the following piece of code should compile fine on C++ but not in C. Only problem is how to test it? It compiled fine with g++ and also with gcc. I'm assuming that g++ is C++ compiler and gcc is C compiler. I've tried it with mingw under Windows. Am I correct? if not then how to compile it using C compiler. int ma...

Eclipse > CDT + Cygwin > How to configure a C++ compiler?

So, I've been looking all over. I can't find anywhere that talks about specifically how to configure Eclipse + CDT to run the gcc / gcc++ compiler. I am running Eclipse on a windows box, but I've installed Cygwin. [edit] I've installed Cygwin, and I've added C:\Cygwin\bin to my path environment variable. I'm now getting this error...

How to turn off gcc compiler optimization to enable buffer overflow

Hello - I'm working on a hw problem that requires disabling compiler optimization protection for it to work. I'm using gcc 4.4.1 on ubuntu linux, but can't figure out which flags are are the right ones. I realize it's architecture dependant - my machine runs w/ 32-bit Intel processor. Thanks. ...

Consistant behaviour of float code with GCC

Hello, I do some numerical computing, and I have often had problems with floating points computations when using GCC. For my current purpose, I don't care too much about the real precision of the results, but I want this firm property: no matter WHERE the SAME code is in my program, when it is run on the SAME inputs, I want it to give ...

Compiling VirtualDiskAPI on cygwin

How can you compile the VirtualDiskAPI on cygwin? I downloaded the windows version of the SDK from here, and put it in my working directory under vmdevkit. I try to compile as follows: gcc -Wall -I./vmdevkit/include -L./vmdevkit/lib -lvixDiskLib -o vmscraper vmscraper.c All my program does is include the files and call connect and dis...

"Error: backward ref to unknown label..." in MinGW inline assembly

Once again, I play with MinGW inline assembly. #include <stdio.h> int foobar(int); int main(){ int n = 0; printf("Number: "); scanf("%d", &n); printf("\n%d",foobar(n)); return 0; } int foobar(int num){ int result = 0; asm(".intel_syntax noprefix\n"); asm("mov eax, num\n"); asm("add eax, 110b\n"); asm("sub eax, 2\n"); as...

Fast implementation/approximation of pow() function in C/C++

I m looking for a faster implementation or good a approximation of functions provided by cmath. I need to speed up the following functions pow(x,y) exp(z*pow(x,y)) where z<0. x is from (-1.0,1.0) and y is from (0.0, 5.0) ...

How to GCC compile without _alloca ?

For some reason, I should use gcc to compile a C file, then link against Visual C++ 2008 project. (I used the current latest gcc version: cygwin gcc 4.3.4 20090804.) But there is one problem: gcc always allocate a big array with _alloca, and VC linker can't resolve the symbol __alloca. for example, int func() { int big[10240]; ...

Incremental compilation in nvcc (CUDA)

I have many structs (classes) and standalone functions that I like to compile separately and then link to the CUDA kernel, but I am getting the "External calls are not supported" error while compiling (not linking) the kernel. nvcc forces to always use inline functions from the kernel. This is very frustrating!! If somebody have figured ...

Problem with the length of path in GCC

Hey, I had a problem with the limitation of paths Here for example I run this command... : String[] cmd = new String[] {"command.com","/C", "Resource\\gcc.exe", "-E", in_path, ">", ...

Calling a method with this pointer from an inherited class becomes const.

class A { } class B : public A { doSomething { C * c = new C(this); } } class C { C(A* copy); } In the following example I get the following error: error: no matching function for call to `C::C(B* const)' I wan't to get the A pointer in the this call but for some reason I can't get this through. Probably so...

GCC generated assembly equivalent to continue statement in C

When a continue statement is used inside a loop in C code, GCC creates a new label with a nop instruction right before the end of the loop block and jumps to it, rather than jump to the end of the loop block itself. For instance, the following C code for (i=0; i<10; i++) { puts("blah\n"); if (i < 10) continue; puts("This sho...

conditional compilation statement in limits.h

I am not able to understand the following statement from the file limits.h. What is the use of this statement and what does it accomplishes? /* If we are not using GNU CC we have to define all the symbols ourself. Otherwise use gcc's definitions (see below). */ #if !defined __GNUC__ || __GNUC__ < 2 ...

Is it possible to install 2 different versions of GCC at the same time ?

I am using Ubuntu 9.10 For a particular piece of code I require GCC 3.2 but I have a higher version. Is it possible to install multiple versions and use whichever one I want to ? ...