gcc

Why does my flex/yacc compiler not compile correctly on another linux machine

On my machine (Windows running cygwin) it compiles correctly. Flex is version 2.5.35 and bison is version 2.3 On linux machine 1 it compiles correctly. Flex is version 2.5.4 and bison is version 1.875c. On linux machine 2 it does not compile correctly. Flex is version 2.5.4 and bison is 2.3. One would expect by looking at the flex/...

Apple's gcc, what's the difference between -arch i386 and -m32 ?

According to Apple's gcc 4.2.1 doc: -arch arch Compile for the specified target architecture arch. The allowable values are 'i386', 'x86_64', 'ppc' and 'ppc64'. Multiple options work, and direct the compiler to produce “universal” binaries including object code for each architecture specified with -arch. This option o...

XCode and the iPhone SDK: C++ Standard Library Type?

Because I'm a novice to all things C++ and gcc related I need to understand something that's potentially critical. If I use .mm files in a new iphone project whose output is a static lib I get this error: "___gxx_personality_v0", referenced from: If I change the C++ Standard Library type from Dynamic (the default) to static the err...

Does GCC's __attribute__((__packed__))...?

Purpose I am writing a network program in C (specifically gnu89) and I would like to simplify things by reinterpreting a certain struct X as big array of bytes (a.k.a. char), sending the bytes over the network, and reinterpreting them as struct X on the other side. To this end I have decided to use gcc's __attribute__((__packed__ )). I ...

Compiling an ANTLR 3 grammar in C.

I've been trying to learn ANTLR and get it working with C output code using this tutorial (also referenced in this question). I successfully got ANTLR to generate the lexer and parser as C source, but I cannot get them to compile using gcc on Mac OS X Snow Leopard (i686-apple-darwin10-gcc-4.2.1). Below is the result when I try to compile...

Precompiled headers and compiling universal objects on OSX

We are using precompiled headers with GCC for our project and build them like this: gcc $(CFLAGS) precompiledcommonlib.h Now I'm building the project on OSX 10.6 and trying to use the nifty feature of building for all architectures at the same time like this: gcc $(CFLAGS) -c -arch i386 -arch x86_64 commonlib.c However, it seems th...

compiler versions

I have some guys here who have code that needs to be compiled with gcc-3.3. We have a CentOS 5.2. When we compile it with their make files, it fails during the link and they say it is because it won't work with gcc-3.4 which is installed already. Is there something I need to tell them to change to make it go, or is it possible to find...

gcov creates .gcov files in the current directory. Is there any way to change this?

I'm running gcov/gcc 4.1.2 on RHEL. When I want to specify a directory for the gcov files. Any ideas on how to do this? ...

How to use the -MG flag in cc 4.4.1?

I've recently upgraded my Ubuntu installation from Jaunty to Karmic. This apparently includes an update of the GNU C compiler, because code that compiled previously no longer does. Running cc 4.4.1 (Ubuntu 4.4.1-4ubuntu8) now produces the following error, on code that worked fine in the cc 4.3.3 (Ubuntu 4.3.3-5ubuntu4): $ make cc -c -M...

GCC memory leak detection equivalent to Microsoft crtdbg.h?

After many years of working on a general-purpose C++ library using the Microsoft MSVC compiler in Visual Studio, we are now porting it to Linux/Mac OS X (pray for us). I have become accustomed and quite fond of the simple memory leak detection mechanism in MSVC: #ifdef DEBUG #define _CRTDBG_MAP_ALLOC #define NEW new( _NORMAL_B...

How to combine shared libraries?

I've got some .so libraries that I'd like to combine into one shared library so that it doesn't depend on the original .so files anymore. The .so files have dependencies to each other. How can I do this? Can I do this? ...

Ignore "initialization from incompatible pointer type" warnings?

Is there a compiler directive in order to ignore the "initialization from incompatible pointer type" warnings in Hardware_MouseDrivers_GPM_Methods and Hardware_MouseDrivers_DevInput_Methods? Turning off warnings globally is not an option though. #include <stdio.h> /* Mouse driver interface */ typedef struct _Hardware_MouseDriver { ...

gccgo linking Error in Ubuntu 9.10 karmic ?

Hi I am trying to compile go file using gccgo , i installed on my ubuntu 9.10 machine . when i compiled $gccgo -c hello.go hello.o file is generated , while trying to link and to form an executable $gccgo -o hello hello.o i get the following error /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../libgo.so: undefined referen...

C -multidimensional array causes Segmentation Fault (GCC)

Why if I change the size of one of the dimensionality of an array I get a run-time Error: "Segmentation Fault?". Example: #include <stdio.h> #define DIM 8 int main(int argc, char **argv) { int a[3][3][3][3][3][3][3][3][3][3][DIM], b; a[1][1][1][1][1][1][1][1][1][1][1] = 2; b=a[1][1][1][1][1][1][1][1][1][1][1]; p...

Suppress Xcode warning? 'weak_import' attribute ignored

Hi, I've got quite a large Xcode project that since an Xcode upgrade is giving me loads of "'weak_import' attribute ignored" warnings, they are coming from WebKit, and a bit of research suggests it's a compiler bug. Is there anyway to suppress them, I'm getting thousands, making the 'real' warnings impossible to find. Cheers MT ...

C - How to access elements of vector using GCC SSE vector extension

Usually I work with 3D vectors using following types: typedef vec3_t float[3]; initializing vectors using smth. like: vec3_t x_basis = {1.0, 0.0, 0.0}; vec3_t y_basis = {0.0, 1.0, 0.0}; vec3_t z_basis = {0.0, 0.0, 1.0}; and accessing them using smth. like: x_basis[X] * y_basis[X] + ... Now I need a vector arithmetics using SSE i...

Disabling NUL-termination of strings in GCC

Is it possible to globally disable NUL-terminated strings in GCC? I am using my own string library, and I have absolutely no need for the final NUL characters as it already stores the proper length internally in a struct. However, if I wanted to append 10 strings, this would mean that 10 bytes are unnecessarily allocated on the stack. ...

How to cross compile from Mac OS X to Linux x86?

Hi, I'm running Mac OS X 10.5.8 and want to compile for target CentOS 5.3 with GCC 4.1.2. How could I: Compile GCC 4.1.2 toolchain and related tools? Use that tool to cross compile for target CentOS 5.3? Any help is greatly appreciated! ...

Code snippet paths in GCC

Background: Keil C51 on a PC, currently moving to GCC (CrossPack-AVR) on an iMac. Since I write firmware for micro's I have a lot of 'driver' source files etc. that I need to include with my programs, e.g. a LCD driver, i.e. reusing code. These code snippets (.c and .h files) live sub folders in a /snippets/ folder, i.e. /snippets...

How to make this C program compile?

When I type gcc gprof-helper.c to compile the program I get these errors: gprof-helper.c: In function `wooinit': gprof-helper.c:38: error: `RTLD_NEXT' undeclared (first use in this function) gprof-helper.c:38: error: (Each undeclared identifier is reported only once gprof-helper.c:38: error: for each function it appears in.) This is t...