gcc

Is there a gcc 4.2 warning similar to Visual Studio's regarding possible loss of data?

Is there a flag for gcc such that conversions from a long to a short will generate a warning about a possible loss of data? I'm working on a C++ application that is compiled for both Visual Studio (2005) and GCC 4.2 (for Mac OS X). The warnings that Visual Studio prints out follow this pattern: : warning C4244: 'argument' : conversion...

Conditionally disable warnings with qmake/gcc?

Hello, I am involved with a software project written in Qt and built with qmake and gcc on Linux. We have to link to a third-party library that is of fairly low quality and spews tons of warnings. I would like to use -W -Wall on our source code, but pass -w to the nasty third-party library to keep the console free of noise and clutter...

legacy gcc compiler issues

We are using a legacy compiler, based on gcc 2.6.0, to cross compile for an old imbedded processor we are still using (yes, it is still in use since 1994!). The engineer that did the gcc port for this chip has long since moved on. Although we might be able to recover the gcc 2.6.0 source from somewhere on the web, the change set for this...

Slow compilation of boost-based unit test suite

Hi all, I use boost.test library to write unit tests for my application. The problem is, when one particular *.cpp file containing test suite grows up to certain size, compilation of that file becomes extremely slow. I use BOOST_AUTO_TEST_CASE macro to define test cases. Boost version is 1.34.1 Build env is autotools + gcc 4.3 under...

Trying to no-op an instruction

Is it possible using GNU tools (gcc, binutils, etc) to modify all occurrences of an assembly instruction into a no-op? Specifically, gcc with the -pg option generates the following assembly (ARM): 0x0: e1a0c00d mov ip, sp 0x4: e92dd800 stmdb sp!, {fp, ip, lr, pc} 0x8: e24cb004 sub fp, ip, #4 ; 0x4 0xc: ebfffffe bl 0 <mco...

C++ operator overloading resolution ambiguity

Hello all, Am trying to move an antique C++ code base from gcc 3.2 to gcc 4.1, as I have run into a few issues. Of all the issues, the following is left me clueless (I guess I spent too much time with Java or I might have forgotten the basics of C++ :-P ). I have a template class template < class T > class XVector < T > { ... te...

C++ new operator thread safety in linux and gcc 4

Soon i'll start working on a parallel version of a mesh refinement algorithm using shared memory. A professor at the university pointed out that we have to be very careful about thread safety because neither the compiler nor the stl is thread aware. I searched for this question and the answer depended on the compiler (some try to be so...

How do I force 64 bit integer arithmetic on OS X?

I am trying to force 64 bit long integers on OS X 10.5.6. running on an Apple MacBook Intel Core 2 Duo. Here is my c code: #include<stdio.h> int main() { long a = 2147483647; /*== 2^32 - 1*/ long aplus1; printf("a== %d. sizeof(a) == %d \n", a, sizeof(a)); aplus1 = a+1; printf("aplus1 = %d \n", aplus1); } Compi...

How do I reference an external C++ namespace from within a nested one?

I have two namespaces defined in the default/"root" namespace, nsA and nsB. nsA has a sub-namespace, nsA::subA. When I try referencing a function that belongs to nsB, from inside of nsA::subA, I get an error: undefined reference to `nsA::subA::nsB::theFunctionInNsB(...)' Any ideas? ...

Use both static and dynamically linked libraries in gcc

I need to distribute a binary that will run on as many x86 Linux distributions as possible. That means that I have to statically link some libraries, like glibc, because the user might not have the version I use. Other libraries have to be dynamically linked, like fontconfig, because it relies on a cache file format and hard coded locati...

How can I add a C-based language to GCC

If I wanted to modify or add my own extensions to C, and add them to the GCC C compiler, what would I need to do? I do not want to propose changes to the language, I want to know how the C compiler actually works. I've had a look at the source code to GCC and it looks as if Objective-C is implemented as a simple parser that generates co...

GCC MIPS-32 Calling Conventions / Stack Frame Definition

There appears to be no definitive standardized stack frame and C language calling conventions (register usage and such) for the MIPS-32 Processor Architecture. That is, it appears to be completely up to the assembler/compiler tool chain to define their own stack frame and calling conventions. I've struggled to find a definitive reference...

Better way to implement a generic atomic load or store in GCC?

I am aware of GCC's builtin atomic operations: http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Atomic-Builtins.html But this list doesn't include very simple operations like load and store. I could implement these on limited architectures with inline assembly (in fact for many like x86 they will be basically just regular mov's), but is ther...

Understanding empty main()'s translation into assembly

Hi, Could somebody please explain what GCC is doing for this piece of code? What is it initializing? The original code is: #include <stdio.h> int main() { } And it was translated to: .file "test1.c" .def ___main; .scl 2; .type 32; .endef .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp ...

Is java.lang.Math.PI equal to GCC's M_PI?

I am coding several reference algorithms in both Java and C/C++. Some of these algorithms use . I would like for the two implementations of each algorithm to produce identical results, without rounding differently. One way to do this that has worked consistently so far is to use a custom-defined pi constant which is exactly the same in b...

How do you link to a specific version of a shared library in GCC

I'm compiling some code which uses libcurl on a Debian Linux system. My dev machine is running Debian 5 but I want the binary to be usable on older Debian 4 systems too. I find that if I specify -lcurl it will link to libcurl.so.4 but Debian 4 systems only have libcurl.so.3 Is there some way I can tell GCC to link to either libcurl.so....

Unresolved symbols when compiling with gcc on OpenSolaris 2008.11

When compiling a simple Netbeans C project that uses sockets I get the following output. I supose the problem is that gcc is not properly linking sockets.h library. Need a foolprof method to solve this. Thanks i advance Running "/usr/bin/make -f Makefile CONF=Debug clean" in /export/home/manu/Escritorio/TP-entrega 2/Application_1 /usr...

gcc makefile error: "No rule to make target ..."

I'm trying to use GCC (linux) with a makefile to compile my project. I get the following error which is can't seem to decipher in this context: "No rule to make target vertex.cpp', needed by vertex.o'. Stop." This is the makefile: a.out: vertex.o edge.o elist.o main.o vlist.o enode.o vnode.o g++ vertex.o edge.o elist.o main.o...

What is the method for optimizing individual functions in a file in GCC 4.1.1?

Various C / C++ compilers have #pragmas to control optimization. For example: CodeWarrior #pragma optimization_level 0 void func_no_opt() { // Some Work - not optimized } #pragma optimization_level 3 void func_full_opt() { // Some Work - optimized } MSVC #pragma optimize("g", off) void func_no_opt() { // Some Work - no...

Update GCC on OSX

So I am a new programmer and I just installed XCode on my Macbook to get the GCC. I think Xcode is the only way for getting GCC on OSX. Now when I run my Hello World application, in C++, g++ comes up saying it is version 4.0.1 but when I look for commands starting with g I also see g++-4.2. Is there any way of making 4.2 default rather t...