gcc

Faster code with another compiler

I'm using the standard gcc compiler in math software development with C-language. I don't know that much about compilers or compiler options, and I was just wondering, is it possible to make faster executables using another compiler or choosing better options? The default Makefile sets options -ffast-math and -O3 and I think both of them...

What does CC?= in a Makefile mean?

I have a Makefile for a C program that has the declaration CC?=gcc Changing it to CC?=g++ does NOT make it compile with g++. Changing it to CC=g++ DOES make it use g++. So I wonder what the ?= operator does? My guess is that it looks at a environment variable to decide which compiler to use and if it's not set then use gcc? Any...

gcc error trying to install PIL in a Python2.6 virtualenv

I have created a virtualenv with the --no-site-packages option. I get an error trying to install PIL: http://pastebin.com/SVqxs1sC ... error: command '/usr/bin/gcc' failed with exit status 1 ---------------------------------------- Command /home/dustin/.virtualenvs/django1.2/bin/python -c "import setuptools; __file__='/home/dustin/.vi...

Strange incompatible assingment of pointers

Hi, I am working on some C code. There is a function like this; void Get(double x_la[], double y_la[], double z_la[]) in the function body, for some other reasons I create; double (*la)[3]; As far as I understood, x_la, y_la and z_la are pointers of the type double. I need to "connect" the pointers involved in "la" wiht the p...

List of all gcc diagnostics

I need a link to a webpage that lists all the error messages and warnings GCC can show; the actual messages, not descriptions. It would be preferable if the list is in the order of most frequently encountered diagnostics. ...

Working with wchar in C

I have this code: #include <stdio.h> #include <wchar.h> int main() { wchar_t *foo = L"ðħ"; wprintf(L"[%ls]\n", foo); return 0; } And when I compile it, it gives me the implicit declaration of function ‘wprintf’ warning. I know that I should link the wchar library during compilation, but how do I do that? ...

pretty print makefiles

The linux kernel (and various other projects including git) have very nice makefiles that hide the giant cc calls into nice little acronyms. For example: gcc -O2 -o cool.o cool.c -llib gcc -O2 -o neat.o neat.c -llib would become: CC cool.c CC neat.c Which is really nice if you have a project with a large number of files and long c...

running gcc in cygwin

Hello i have instlled cygwin in my system.But when i try to use gcc command it is saying bash: gcc: command not found can any one please provide me the solution please. ...

Handle LPDWORD,LPSTR in GCC

I have a C++ program that uses LPDWORD, DWORD, etc. When I compile using GCC, it throws an error. How do I handle LPDWORD, DWORD, LPBYTE, and LPTSTR in GCC? ...

atomic swap with CAS (using gcc sync builtins)

Can the compare-and-swap function be used to swap variables atomically? I'm using C/C++ via gcc on x86_64 RedHat Linux, specifically the __sync builtins. Example: int x = 0, y = 1; y = __sync_val_compare_and_swap(&x, x, y); I think this boils down to whether x can change between &x and x; for instance, if &x constitutes an op...

/usr/bin/ld: cannot find -lemu

I am attempting to install an application. During compilation it fails with the following error: /usr/bin/ld: cannot find -lemu I have installed the libemu library, and it now currently resides in /opt/libemu/. However, when I try and compile my application the library is not found. Is there any way to correct this? EDIT: It also l...

Is there any way to make gcc print offending lines when it emits an error?

I have a large codebase that I've been tasked with porting to 64 bits. The code compiles, but it prints a very large amount of incompatible pointer warnings (as is to be expected.) Is there any way I can have gcc print the line on which the error occurs? At this point I'm just using gcc's error messages to try to track down assumptions t...

How to configure gcc to use an alternate glibc?

To use the loader in the alternate glibc installation at /usr/test, I have change the loader path /lib/ld-linux-x86-64.so.2 to /usr/test/lib/ld-linux-x86-64.so.2 under the *link section in the gcc specs file. I have also pointed CPATH to /usr/test/lib/include and LIBRARY_PATH to /usr/test/lib. Is it the correct way to use the alternate ...

Alternatives to the --sysroot switch of gcc?

The --sysroot switch is useful when you don't want the headers/libraries in the standard paths affect your build. --sysroot=dir: Use dir as the logical root directory for headers and libraries. For example, if the compiler would normally search for headers in /usr/include and libraries in /usr/lib, it will instead search di...

combine two GCC compiled .o object files into a third .o file

How does one combine two GCC compiled .o object files into a third .o file? $ gcc -c a.c -o a.o $ gcc -c b.c -o b.o $ ??? a.o b.o -o c.o $ gcc c.o other.o -o executable If you have access to the source files the -combine GCC flag will merge the source files before compilation: $ gcc -c -combine a.c b.c -o c.o However this only wo...

base destructor called twice after derived object?

hey there, why is the base destructor called twice at the end of this program? #include <iostream> using namespace std; class B{ public: B(){ cout << "BC" << endl; x = 0; } virtual ~B(){ cout << "BD" << endl; } void f(){ cout << "BF" << endl; } virtual void g(){ cout << "BG" << endl; } private: int x; ...

How to build mach-0 for different architectures?

I have some dylibs to load from python with ctypes. I can load libbass.dylib without problem, but I can't load the self-compiled libmp3lame.dylib. Here is the error I get. OSError: dlopen(libmp3lame.dylib, 6): no suitable image found. Did find: libmp3lame.dylib: mach-o, but wrong architecture Then, I inspect the file typ...

What is the explanation for "warning: assuming that the loop is not infinite"

I had just taken the decision to change as many variables from unsigned to int and upon recompiling the code in question, was greeted by this warning message: freespace_state.c:203: warning: assuming that the loop is not infinite The line in question: for (x = startx; x <= endx; ++x, ++xptr) This loop is 60 lines of code (inc white...

destructor and copy-constructor calling..(why does it get called at these times)

Hello there, I have the following code #include <iostream> using namespace std; class Object { public: Object(int id){ cout << "Construct(" << id << ")" << endl; m_id = id; } Object(const Object& obj){ cout << "Copy-construct(" << obj.m_id << ")" << endl; m_id = obj.m_id; } Object& oper...

Cygwin GCC + WinXP cmd.exe does nothing

My basic problem is that if I run GCC from the windows command line (cmd.exe in Windows XP) and it does nothing: no .o files are created, no error messages, nothing. It will only throw an error message if I use DOS-style paths, but nothing else. When I run from the Cygwin shell then it will throws error messages as appropriate for the ...