gcc

disable specific warnings in gcc

On microsoft compilers, specific warnings can be disabled with a #pragma, without disabling other warnings. This is an extremely useful feature if the compiler warns over something that "has to be done". Does GCC at this point have a similar feature? It seems like an obvious enough feature that its unimaginable that it wouldn't have t...

How do I obtain/use LibUUID?

I'm trying to replace a call to ::CoCreateGUID so I can generate GUIDs in a C++ program on Linux. I understand that libuuid (http://linux.die.net/man/3/libuuid) supports this, and I've read this question (http://stackoverflow.com/questions/153676/guids-in-a-c-linux-gcc-app). I'm a bit new to Ubuntu/GCC/Linux, so I've started off like t...

Why does my static build require shared libraries?

Why does my static build require shared libraries? Every so often I get these warnings from my linker... (at the moment it is happening with openssh-5.2p1) The warnings look similar to: "Using 'function' in statically linked applications requires at runtime the shared libraries from the glibc version used for..." When I google, I only...

Any MSVC equivalent to GCC '-include' flag?

In GCC you can use the '-include ' flag to automatically include a file in the compilation unit. Is there any equivalent method for this in MSVC? ...

Why are static library headers not found?

I've used Clint Harris' tutorial to set up code sharing between projects, and everything works just as expected on my computer. But on my co-worker's machine, it seems the compiler doesn't find the header file from the static library project when he builds. My co-worker got my project by cloning a git repository. We've gone through all ...

Problem with gprof on OS X: [program] is not of the host architecture

I'm having trouble running gprof on OS X. The file test.c is: #include <stdio.h> int main() { printf("Hello, World!\n"); return 0; } and my terminal looks like: $ gcc -pg test.c $ gcc -pg -o test test.c $ ./test Hello, World! $ gprof test gprof: file: test is not of the host architecture Edit: also, it doesn't generate the fil...

Order of local variable allocation on the stack

Take a look at these two functions: void function1() { int x; int y; int z; int *ret; } void function2() { char buffer1[4]; char buffer2[4]; char buffer3[4]; int *ret; } If I break at function1() in gdb, and print the addresses of the variables, I get this: (gdb) p &x $1 = (int *) 0xbffff380 (gdb) p...

Compiling code using gcc and SciTE?

Hello, I'm trying to compile C/C++ code from an external source using SciTE. The SciTE has a built-in feature where it searches for the gcc compiler and libraries in the same folder. The problem occurs if I try to compile from SciTE externally. Compiling with F5 (compile and run) or CTRL-F7 (compile) results in SciTE not being able to f...

How to detect if I can run executables compiled for gcc4 on a box?

On a production Linux box without development tools installed (e.g. no headers, no gcc) how do you figure out if it will be able to execute stuff: compiled under gcc4.1.2 as opposed to gcc3.3.3 (there was a change in ELF between version 3 and 4 I think) compiled for 64 bit as opposed to 32 bit executables We have some legacy librarie...

Make GDC front end emit intermediate C/C++ code?

While investigating the D language, I came across GDC, a D Compiler for GCC. I downloaded the version for MinGW from here: http://sourceforge.net/projects/dgcc/files/ Documentation was almost nonexistent, but it did say that most of the command line switches were the same as for the GCC compiler. However, that doesn't help me much, s...

Compilng C/C++ makefile files under Windows (XP)

I'm trying to use a Python library (pyMedia) that has some non-Python requisites libraries. (libogg, libvorbis, liblame, and libfaad2 - this isn't relevant to the question specifically). libogg requires you to manually compile it from the source and comes with a makefile. I have GCC installed for Windows. How would I go about compiling ...

Error linking with GCC 4.3.2 on RHEL 5.3 and libstdc++.so. Any GCC gurus?

Trying to use the RHEL5.3 GCC 4.3.2 compiler to build my software on that platform. I get the following error no matter what I try when compiling with -O2, but it builds fine without optimization. Any ideas? /usr/bin/ld: myapp: hidden symbol `void std::__ostream_fill<char, std::char_traits<char> >(std::basic_ostream<char, std::char_tr...

Is it possible to use GCC without Cygwin or MinGW?

GCC is a very well respected multi-language compiler (from what I've gathered). One thing I've not been able to definitively find out is: Is it possible to use GCC on windows without anything extra like Cygwin or MinGW? I've learned that if you use GCC on Cygwin, there is a dependency on a DLL. If you use GCC with MinGW, you eliminate ...

Linking VS2005 static library with gcc in Windows

Is it possible to link a static library built with VS2005 into an application that is to be built with gcc (in Cygwin)? ...

How to get rid of special characters in a text file? (*nix)

I've got a source code file, that started as a copy of some sample code from a webpage. It was created and edited under Windows and compiled with no problems. But under Mac's I get a load of obscure errors, like: ../MyProgram.cpp:1: error: stray '\255' in program ../MyProgram.cpp:1: error: stray '\254' in program ../MyProgram.cpp:1: er...

Optimisation of division in gcc

Here's some code (full program follows later in the question): template <typename T> T fizzbuzz(T n) { T count(0); #if CONST const T div(3); #else T div(3); #endif for (T i(0); i <= n; ++i) { if (i % div == T(0)) count += i; } return count; } Now, if I call this template function wit...

Problem with gcc gcse optimizer on PowerPC

Hi there. I noticed with -O2 level optimization using gcc 4.1 built on IBM AIX (for use with 5.3 and 6.1) that a bunch of lwz rxxx,offsetyyy(r2) sequences are added to an inline sequence, before bctrl (calling a method or function) is done. After the register is loaded, it is never used again after the return from the method or function...

how to return an script in c / gcc?

guys, had been years since I wrote my last line in C, now I'm trying to start again to make some function and use than as an extension for php. this is an easy function to create "small urls" lets say: a0bg a0bf a0bh the problem I'm having is when I have to "increment" an string like zzz then I got: Bus Error otherwise if I increme...

Develop In C++ For Windows CE In Linux

Hello, How i can develop and compile command line C++ programs in my Linux Ubuntu, for my Jornada 720 that have a Windows CE 3.1(HPC 2000), something like a compiler like that for Palm or something like gcc, and a tutorial of development and compiling will be very nice, remember that i want to build command line programs to Windows CE, ...

C coding practices for performance or code size - beyond what a compiler does

I'm looking to see what can a programmer do in C, that can determine the performance and/or the size of the generated object file. For e.g, 1. Declaring simple get/set functions as inline may increase performance (at the cost of a larger footprint) 2. For loops that do not use the value of the loop variable itself, count down to zero in...