gcc

g++ 4.4.x bug ?

I have build a g++ v4.4 from source by using the archives provided by gcc.gnu.org. But the resulting g++ cannot compile some of our projects c++ files. I am receiving a message simply saying: assembler error. It turned out that the assembler chokes on some extremely long symbol names, e.g. symbols names with a length of more then 2k. A...

Howto compile for Windows on Linux with gcc / g++ ?

Dear developers, I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with g++ -Wall -lglut part8.cpp -o part8 So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed? I don't have Windows, so it would be really cool, if I could do that...

Setting up MinGW with Eclipse Galileo on Windows.

Couldn't get it working on Windows 7 64 bits. ...

Why is this program not showing the first line again and again?

#include <stdio.h> #include <stdlib.h> #include <string.h> char *readLine(FILE *inFile) //Simply reads line in a text file till "\n" { char *line = realloc(NULL, 1); char c; int i=0; while (!feof(inFile)) { c = fgetc(inFile); if (ferror(inFile)) printf("Error reading"); if (c == 10) ...

How to get `gcc` to generate `bts` instruction for x86-64 from standard C?

Inspired by a recent question, I'd like to know if anyone knows how to get gcc to generate the x86-64 bts instruction (bit test and set) on the Linux x86-64 platforms, without resorting to inline assembly or to nonstandard compiler intrinsics. Related questions: Why doesn't gcc do this for a simple |= operation were the right-hand sid...

how to raise warning if return value is disregarded - gcc or static code check?

I'd like to see all the places in my code (C++) which disregard return value of a function. How can I do it - with gcc or static code analysis tool? Bad code example: int f(int z) { return z + (z*2) + z/3 + z*z + 23; } int main() { int i = 7; f(i); ///// <<----- here I disregard the return value return 1; } Update: it ...

Newbie C #include Question

I roughly understand the rules with what #include does with the C preprocessor, but I don't understand it completely. Right now, I have two header files, Move.h and Board.h that both typedef their respective type (Move and Board). In both header files, I need to reference the type defined in the other header file. Right now I have #incl...

Is there a similar option in Visual Studio like `-iquote` in GCC?

I found there was an option -iquoteDIR in GCC to control the search path just for #include "FILE" other than #include <FILE>. But I didn't find a similar option in Visual Studio. Is there anybody knows it? ...

make error occured in gcc c++ compiler with mingw linker

Build of configuration Release for project testcase make all Building file: ../atest.cpp Invoking: GCC C++ Compiler g++ -I"C:\cppunit\include" -I"C:\cppunit\include\cppunit\extensions" -I"C:\mingw\bin" -O3 -Wall -c -fmessage-length=0, -Wl,-subsystem,console -MMD -MP -MF"atest.d" -MT"atest.d" -o"atest.o" "../atest.cpp" cc1plus.exe: erro...

Using a Linker Script on Mac OS X

Is there any way to use a linker script with ld on Mac OS X? The GNU ld program on Linux accepts a -T <scriptname> option, but on Mac OS -T is an unknown command option. Using an alternative installation of GCC is okay with me, if that solves the problem. ...

'hidden fstat' linking error with gcc4.2 on Ubuntu amd64

I've got a pile of code that builds in many places. I just turned on the build on Ubuntu 8.0.4 LTS with gcc 4.2 and ccache, and received for my trouble an error from the linker that I've never seen before. Googling leads to suggestions that I've got a shared object built with naked ld involved, but, in fact, I do not. What do I have? /u...

How exactly does __attribute__((constructor)) work?

It seems pretty clear that it is supposed to set things up. When exactly does it run? Why are there two brackets? Is __attribute__ a function? A macro? Syntax? Does this work in C? C++? Does the function it works with need to be static? When does __attribute__((destructor)) run? Example in Objective C: __attribute__((constructor)) s...

Why is Apple's gcc output mixed up when compiling for multiple architectures?

When running gcc on the command line in OS X, every now and then, I'll get warnings and/or errors. But I'm always compiling for multiple architectures (with the -arch option), and since gcc spawns several processes for each architecture, errors will constantly get garbled. For example, just running gcc (options) -### will result in Usin...

How do I recover a semaphore when the process that decremented it to zero crashes?

I have multiple apps compiled with g++, running in Ubuntu. I'm using named semaphores to co-ordinate between different processes. All works fine except in the following situation: If one of the processes calls sem_wait() or sem_timedwait() to decrement the semaphore and then crashes or is killed -9 before it gets a chance to call sem_...

Howto add a link to a library in autoconf configure script / makefile

Hi, I am an autotools newb and I have difficulties figuring out howto easily link a specific library into one of the configured targets. I have a source package that I want to build the usual way: ./configure && make && make install Unfortunately one of the cpps has a missing reference to another library. Compiling it by hand (adjustin...

Objective-C property assignment returns the assigned value?

Say I have the following: @interface MyClass : NSObject { NSString* _foobar; } @property (nonatomic, retain) NSString* foobar; @end @implementation MyClass @dynamic foobar; - (void) setFoobar:(NSString*)fbSet; { [_foobar release]; _foobar = [fbSet retain]; } - (NSString*) foobar; { return _foobar; } @end Then: MyClass* mcInst = [[[M...

Xcode: gcc-4.2 failed with exit code 1

Hi! I'm working on a game for the iPhone where I use the Oolong engine for rendering, and now I just tried to update my project to the newest version. However - now I get the following error when I try to compile: gcc-4.2 failed with exit code 1 in the build results I see in which cpp file the error happens, but I don't see any addit...

GCC dies trying to compile 64bit code on OSX 10.6

I have a brand-new off-the-cd OSX 10.6 installation. I'd now like to compile the following trivial C program as a 64bit binary: #include <stdio.h> int main() { printf("hello world"); return 0; } I invoke gcc as follows: gcc -m64 hello.c However, this fails with the following error: Undefined symbols: "___gxx_perso...

Is there any way to compile gcc to support a single language?

I want to compile gcc so i can use the mips R2000 microprocessor compiler inorder to use NestedVM a way of targeting any executable to the java vm; but I don't want it to compile the modules for other languages than mine or architectures other than the R2000 or the Mips family. ...

C++ linker errors, Undefined references to Items that should be referenced from a Share Object

I am building a library, called physgameengine, to aid in building games. This game library links against several libraries, including: Ogre3d, Bullet Physics and SDL, which are in the library files libOgreMain-1.6.5.so, libBulletCollision.a, libBulletDynamics.a, libBulletSoftBody.a, libSDL-1.2.so.0. This Library/Shared object appears to...