gcc

LLVM vs GCC MIPS code generation, any benchmarks?

I'm interested in knowing what is "best" free/OSS compiler for MIPS code, GCC or LLVM, or is there anything even better than those? I'm interested in knowing more about fast and memory constrained generated Assembly code than code size. In other words, does llvm-opt do the job better than gcc -O3? ...

Why does malloc allocate a different number of bytes than requested?

I have this piece of code #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> int main(){ void *a, *b; a=malloc(16); b=malloc(16); printf("\n block size (for a): %p-%p : %li",b,a,b-a); a=malloc(1024); b=malloc(1024); printf("\n block size (for a): %p-%p : %li",b,a,b-a); } This shouldn't display the t...

How to deal with compiler optimization problems

I'm having an annoying problem with my iPhone app. Whenever I set the optimization level to something other than "None", I get computation errors. This only happens in when building for the iPhone SDK (the iPhone Simulator is always fine). I wouldn't mind disabling optimizations in release mode, but the application is a tiny bit too s...

Any way in CMake to require GCC version 4+?

I am using some features that are provided in GCC v4+ and would like CMake to find GCC v4 compiler and if it does not find it, return an error stating GCC v4 is required. Anyone have any modules / ideas on how to do something like this? Thanks. ...

Make the C preprocessor ignore certain #include directives

Hi folks! I use a parser generator here, that unfortunately insists on putting a #include <some/file.h> at the top of every generated source file. The header has since long been renamed. While it is no problem forcing the compiler (gcc) to use the new header with -include new/header.h, removing the above directive from every generate...

Compile old C++ unix application for using in windows

I need to have a windows executable for some code which was written in 1994 for UNIX. I tried to do this from cygwin environment. The C++ standard was changed from this time and the standard libraries too. I tried to use -std= and -traditional-cpp options, but that options didn't helped me at all. I also found that -fno-for-scope and -f...

Is there an advantage to upgrade Binutils from 2.16.1 to 2.19? Why?

In the PSPSDK (Homebrew) we are using the Binutils 2.16.1 to assemble and link the code for the PlayStation Portable, however that release is getting quite outdated (3 versions have superseded it). The community and me have been updating the GCC and newlib to the latest stable versions and everything seems to work with the old binutils. ...

Suppressing Linking Errors in G++ 3.4.6

Don't ask why, but is there any way to suppress a failed linking error? Such as: undefined reference to BLANK This is in GCC 3.4.6 ...

When can't an object be converted to a reference?

I want to compile the following line of code from http://code.google.com/p/enhsim: enh::eout << enh::setw(26); gcc gives the following error: error: no match for 'operator<<' in 'enh::eout << enh::setw(26)' But the EnhSimOutput class (of which enh::eout is an instance) does declare: EnhSimOutput& operator<< (setw& p); This probl...

How to force gcc preprocessor to preserve whitespace?

For the code: int i; gcc preprocessor outputs: int i; How to force it to preserve whitespace? I call preprocessor with: gcc -E somefile.c command. ...

Bash: How to feed a command with the multiple results generated by one subcommand

Hi, I want to process each source code file after it has been preprocessed: myprocess `gcc -E file1.c` myprocess `gcc -E file2.c` ... myprocess `gcc -E fileN.c` This gets tedious so how do I make this a single command? That is, something along the line: myprocess SOMETHINGMAGIC(gcc -E file*.c) Thanks in advance! ...

Statically linking to a dynamic library. glibc

So. I have a problem where I have two versions of GCC on a machine. 3.4.6 and 4.1 This is due to some dependency issues with a new piece of software. (requires glibc 4.1) When I go to link this new software with the 4.1 libraries it links fine. However, when it comes to executing the software it can't find the library, because it is...

How to use multiple versions of GCC

We have a new application that requires glibc 2.4 (from gcc 4.1). The machine we have runs on has gcc 3.4.6. We can not upgrade, and the application must be run on this machine. We installed gcc 4.1, however, when it comes to compile time it is using all the includes, ect, from 3.4.6. How do we get around this? Any suggestions...

What to do about wrong "control reaches end of non-void function" gcc warning?

$ cat t.cpp int sign(int i) { if(i > 0) return 1; if(i == 0) return 0; if(i < 0) return -1; } $ g++ -c t.cpp -Wall t.cpp: In function ‘int sign(int)’: t.cpp:5: warning: control reaches end of non-void function $ What do I do about this? Stop using -Wall as it's clearly wrong? Add a bogus return 0 at the end? Clutter the co...

Force static linking of library linked to Xcode target?

My Xcode target links against hdf5 library (using the Link Binary with Libraries build phase). libhdf5 is installed using MacPorts, thus /opt/local/lib contains both the dynamic (.dylib) and static (.a) versions of the library. The text output from the build shows that there is, as expected, a -lhdf5 in the linking step of the build. gc...

Dealing with "C compiler cannot create executables" in Cygwin

Whatever I try to compile in Cygwin I get the following output: checking for mingw32 environment... no checking for EMX OS/2 environment... no checking how to run the C preprocessor... gcc -E checking for gcc... gcc checking whether the C compiler (gcc ) works... no configure: error: installation or configuration problem: C compiler ...

error: ‘NULL’ was not declared in this scope

I get this message when compiling C++ on gcc 4.3 error: ‘NULL’ was not declared in this scope It appears and disappears and I don't know why. Why? Thanks. ...

C++. Is it possible that a RNG gives different random variable in two different machines using the same seed?

Hi everybody, I have this long and complex source code that uses a RNG with a fix seed. This code is a simulator and the parameters of this simulator are the random values given by this RNG. When I execute the code in the same machine, no matter how many attempts I do the output is the same. But when I execute this code on two differe...

How to detect what CPU is being used during runtime ?

How can I detect which CPU is being used at runtime ? The c++ code needs to differentiate between AMD / Intel architectures ? Using gcc 4.2. thanks in advance, vivekian ...

shared_ptr in std::tr1

I am working on a platform with a gcc compiler however boost cannot compile on it. I am wondering what is the proper way to include the shared_ptr in std:tr1 on gcc? the file i looked in said not to include it directly, from what i can tell no other file includes it either :| ...