gcc

Default flags for gcc compiler in Eclipse

I want all my C programs to be compiled with the options -Wall -pedantic -ansi by default. Is there a way to have Eclipse add these flags to the compiler command by default for all projects? ...

Unable to compile basic GLIB program after GLIB install

I can't seem to compile this basic program using glib.h... #include glib.h #include stdio.h int main () { return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ; return 0; } glib.h is located in /usr/local/include/glib-2.0 So I compiled with $ gcc -v -c -mcpu=v9 -I/usr/local/include/glib-2.0 testme2.c ...

ELF shared library: relocation offset out of bounds

There is a software package elfutils which includes a program called eu-elflint for checking ELF binaries (just as lint for C - hence the name). Just for curiosity I have checked our own shared libraries with this tool and it found a lot of issues, e.g.: eu-elflint libUtils.so section [ 2] '.dynsym': _DYNAMIC symbol size 0 does not ma...

Why is this code slower even if the function is inlined?

I have a method like this : bool MyFunction(int& i) { switch(m_step) { case 1: if (AComplexCondition) { i = m_i; return true; } case 2: // some code case 3: // some code } } Since there are lots of case statements (more than 3) and the function is becoming large, ...

gcc optimization, const static object, and restrict

I'm working on an embedded project and I'm trying add more structure to some of the code, which use macros to optimize access to registers for USARTs. I'd like to organize preprocessor #define'd register addresses into const structures. If I define the structs as compound literals in a macro and pass them to inline'd functions, gcc has...

shared library locations for matlab mex files:

hello; I am trying to write a matlab mex function which uses libhdf5; My Linux install provides libhdf5-1.8 shared libraries and headers. However, my version of Matlab, r2007b, provides a libhdf5.so from the 1.6 release. (Matlab .mat files bootstrap hdf5, evidently). When I compile the mex, it segfaults in Matlab. If I downgrade my vers...

linking <iostream.h> in linux using gcc

I'm trying to run my very first c++ program in linux (linux mint 8). I use either gcc or g++, both with the same problem: the compiler does not find the library I am trying to import. I suspect something like I should either copy the iostream.h file (which I don't know where to look for) in the working folder, move my file to compile ...

Implement piping ("|") using C..(fork used)

#include<stdio.h> #include<unistd.h> #include<stdlib.h> int main(int argc,char **argv) { int fd[2]; pid_t childpid; pipe(fd); childpid=fork(); if (childpid == -1) { perror("Error forking..."); exit(1); } if (childpid) /*parent proces*/ //grep .c { wait(&childpid); //...

Combining Java and C without gcj -- move C to Java or Java to C?

First, I have no experience doing this. But like the beginning of any good program, I have problem that I need to fix, so I'm willing to learn. So many of you are probably already familiar with pdftk, the handy utility for handling various pdf-related tasks. So far as I can tell, most of these features are available in much newer, light...

how can I get the ARM MULL instruction to produce its output in a uint64_t in gcc?

Hello, I would like to introduce some assembly code into a c99 codebase. I want to use the UMULL instruction from the ARM CPU to multiply 2 uint32_t and get the result immediately into a uint64_t. Now a uint64_t needs 2 registers, so how do I specify the output and the constraints of the asm block? ...

Opengl: GL_DEPTH_COMPONENT24 not defined

Good afternoon, The setup: I've never done any gl programming. I'm attempting to compile some opengl driver code that compiles in other environments. I'm using mingw on windows in the hope that using gcc on both linux and Windows would make my life easier... The problem: The second parameter of the following isn't defined anywhere:...

c++ runtime error? how to solve this and check?

#include<iostream> using namespace std; int main() { int hash, opp, i, j, c = 0; //cout<<"enter hasmat army number and opponent number\n"; while(cin>>hash>>opp) { cout<<opp-hash<<endl; } } time limit for this problem: 3.000 seconds how can i verify and test this condition? i'm submitting this to a compu...

Strange compile error: conflicting types / previous declaration are identical

Hello, I am trying to compile a static library on OSX 10.5 that links to a library that includes . The error message I'm getting is confusing because the conflicting type apparently conflicts with itself. Compiler message: In file included from /usr/local/include/jasper/jas_math.h:79, from /usr/local/include/jasper.h...

automatically skipping/ignoring external code in gdb

anybody know how to tell gdb to only enter code that is in your project? I know it's hard for a debugger to know what is "in the project" and what is a library....but I thought some naive checks could help, eg don't look in any files that aren't in the users home directory. I frequently have code like this: MyFunction(complexVarable, co...

Debugging of CygWin gcc compiled programs by Visual Studio 2008

Is it possible to debug Windows hosted programs compiled by cygwin gcc by using Visual Studio debugger? ...

GCC preprocessor question

Is it possible to instruct the GCC preprocessor not to remove comments when processing files? ...

Why does g++ generate multiple (weak) similar symbols ?

I'm looking at the output of nm -C 0804a86a W ForkMessageHandler::ForkMessageHandler() 0804a86a W ForkMessageHandler::ForkMessageHandler() 0804a6fa T ForkMessageHandler::~ForkMessageHandler() 0804a698 T ForkMessageHandler::~ForkMessageHandler() 0804a698 T ForkMessageHandler::~ForkMessageHandler() 0804a800 W MultiMessageHandler::MultiMe...

Python Build Problem on Mac OS 10.6 / Snow Leopard

I'm encountering a build problem for Python 2.6.4 on Snow Leopard. Mac OS X 10.6 Yonah CPU, 32-bit gcc-4.2.1 Update I Solved by removing all non-standard includes and libraries from CFLAGS (there happened to be a uuid/uuid.h in there ...). Still, it compiled despite the error describe below, with /usr/include/hfs/hfs_format.h:765 ...

MinGW vs Visual Studio 2008 output code quality

A few days ago I was told that recent versions of g++ produce "better" x86 code than MSVC 2008. Basically GCC with full optimization produces faster applications than MSVC with full optimizations. While it's certainly correct to state that this, if true, depends a great deal on the application and the C++ code used (and I'm in the proce...

Compiling nonessential object files with GCC

Consider the following example g++ a.o b.o c.o -o prog If it is the case that c.o does not contribute any executable code to prog, nor are there any dependencies on c.o in any of the other files, will GCC yet include the contents of c.o in prog? Said another way, aside from compilation time, what (if any) negative consequences can th...