gcc

gcc architecture question

Hi, I'm compiling my program with architecture set to -mtune=i386 However, I'm also linking statically against several libs (libpng, zlib, jpeglib, vorbisfile, libogg). I've built these libs on my own using configure and make, so I guess these libs were built with architecture being set to my system's architecture which would be i686...

auto vectorization on double and ffast-math

Why is mandatory to use -ffast-math with g++ to achieve vectorization of loop using doubles? I don't like ffast-math because I don't want to loose precision. ...

How can I link to a specific glibc version?

When I compile something on my Ubuntu Lucid 10.04 PC it gets linked against glibc. Lucid uses 2.11 of glibc. When I run this binary on another PC with an older glibc, the command fails saying there's no glibc 2.11... As far as I know glibc uses symbol versioning. Can I force gcc to link against a specific symbol version? In my concret...

warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’

I think this code and error is self-explanatory, but I don't know why? Environment: OS: Mac OS X 10.6.1 Compiler: i686-apple-darwin10-gcc-4.2.1 code: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <netdb.h> 4 #include <sys/socket.h> 5 6 int 7 main(int argc, char **argv) 8 { 9 char *ptr, **pptr; 1...

Link one shared library static to my shared library

I am struggeling a little bit with some options for linking on a project I am currently working on: I am trying to create a shared library which is linked against 2 other libraries. (Lets call them libfoo.so and libbar.so) My output library has to be a shared library and I want to static link libfoo.so to the resulting library, but libb...

adding virtual function to the end of the class declaration avoids binary incompatibility?

Could someone explain to me why adding a virtual function to the end of a class declaration avoids binary incompatibility? If I have: class A { public: virtual ~A(); virtual void someFuncA() = 0; virtual void someFuncB() = 0; virtual void other1() = 0; private: int someVal; }; And later modify this class decl...

Demystifying gcc under lpthreads

in these i'm playing with thread library and trying to implement some functions. One of the tutorial says that to run the program use : gcc -lpthread -lrt -lc -lm project1.c scheduler.c -o out first of all i need deep understanding of what is gcc doing in each line, lpthread is used for what? what are the contributions of lrt -lc -l...

C++ : Declaring the array size with a non-constant variable

I always thought that when declaring an array in C++, the size has to be a constant integer value. For instance : int MyArray[5]; // correct or const int ARRAY_SIZE = 6; int MyArray[ARRAY_SIZE]; // correct but int ArraySize = 5; int MyArray[ArraySize]; // incorrect Here is also what is explained in The C++ Programming Language,...

Valgrind 'noise', what does it mean?

When I used valgrind to help debug an app I was working on I notice a huge about of noise which seems to be complaining about standard libraries. As a test I did this; echo 'int main() {return 0;}' | gcc -x c -o test - Then I did this; valgrind ./test ==1096== Use of uninitialised value of size 8 ==1096== at 0x400A202: _dl_new_o...

pow doesn't accept the second parameter to be a variable on gcc

pow doesn't accept the second parameter to be a variable on gcc The following code works fine on VC++10 // file test.cc #include "stdafx.h" #include <stdio.h> #include <math.h> int main(void) { double x = 10; int y = 20; printf("%f\n", pow(x, y)); return 0; } But the following code doesn't not work on gcc: // tes...

Including C header file with lots of global variables

I have an include file with 100+ global variables. It's being used in a library, but some programs that I'm linking the lib to also need to access the globals. The way it was built: // In one library .c file #define Extern // In the programs that use the globals #define Extern extern // In the .h file Extern int a,b,c; I had a hard...

gcc: how to not compile with warnings

I would like to know if there is any gcc flag that doesn't compile to an object file, if there are warnings in the respective source file. Thanks. ...

g++ How to get warning on ignoring function return value

lint produces some warning like: foo.c XXX Warning 534: Ignoring return value of function bar() From the lint manual 534 Ignoring return value of function 'Symbol' (compare with Location) A function that returns a value is called just for side effects as, for example, in a statement by itself or the left-hand side...

How to remove strings from a compiled binary (.so)

How do I remove strings from / obfuscate a compiled binary? The goal is to avoid having people read the names of the functions/methods inside. It is a dynamic library (.so) compiled from C++ code for Android with the NDK tools (includes GCC) I compile with -O3 and already use arm-eabi-strip -g mylib.so to remove debugging symbols, but ...

gcc compiler error in copy ctor: "expected primary-expression before > token"

Here's my code. It compiles in VS2005 but not in gcc. Any ideas template<class T> Derived<T>::Derived(const Derived<T>& in) { Base<T>::Base<T>(in); //ERROR here } "expected primary-expression before > token" ...

C++ - No match for 'operator=' when compiling using GCC

Hello! I recently tried building my own shared and weak pointers. Code that compiles using Visual Studio doesn't compile in GCC (4.5.0) with the following error: main.cpp: In function 'int main()': main.cpp:18:27: error: no match for 'operator=' in 'wp1 = weak_ptr<int>(((const shared_ptr<int>&)((const shared_ptr<int>*)(& sp1))))' weak_p...

How do I install every libs in Devel group of Cygwin?

Is there a way to install every bin in a group of softwares (like devel)? Thank you. ...

C++ - gcc-specific warnings

Hi! Got the following warning output when using GCC 4.5.0 & MinGW. Warning: .drectve `-aligncomm:___CTOR_LIST__,2 ' unrecognized Warning: .drectve `-aligncomm:___DTOR_LIST__,2' unrecognized What does it mean? I guess it's version-specific, because GCC 4.3.4 under cygwin didn't give that warning on the same project. If anyone had the ...

Is typeid of type name always evaluated at compile time in c++ ?

I wanted to check that typeid is evaluated at compile time when used with a type name (ie typeid(int), typeid(std::string)...). To do so, I repeated in a loop the comparison of two typeid calls, and compiled it with optimizations enabled, in order to see if the compiler simplified the loop (by looking at the execution time which is 1us ...

recommending gcc to inline the function

I don't know how feasible it is and how sensible is this question here. Is there any changes that we can make in makefile to recommend GCC inline all the function although the functions are not inlined during the declaration or nowhere in the source file. ...