gcc

Make install - but not to default directories?

I want to run 'make install' so I have everything I need, but I'd like it to install the things in their own folder as opposed to the system's /usr/bin etc. is that possible? even if it references tools in the /usr/bin etc.? ...

Dereferencing type-punned pointer will break strict-aliasing rules

Hi there, I used the following piece of code to read data from files as part of a larger program. double data_read(FILE *stream,int code) { char data[8]; switch(code) { case 0x08: return (unsigned char)fgetc(stream); case 0x09: return (signed char)fgetc(stream); case 0x0b:...

what does "BUS_ADRALN - Invalid address alignment" error means?

We are on HPUX and my code is in C++. We am getting "BUS_ADRALN - Invalid address alignment" in my executable on a function call. What does this error means? Same function is working many times then suddenly its giving core dump. in GDB when i try to print the object values it says not in context. Any clue where to check? Thanks in Adv...

c++ cout with float producing strange results

Currently I have the following: float some_function(){ float percentage = 100; std::cout << "percentage = " << percentage; //more code return 0; } which gives the output percentage = 100 However when I add some std::endl like so: float some_function(){ float percentage = 100; std::cout << "percentage = " ...

How to get around "multiple defined symbols" in linking with gcc.

I am using an older system that has gcc 2.95.3, I have to link in two objects that although they have nothing to do with each other, they each have similarly named methods. I can't rename either of them, but I would hope there is a way to build them as to not have the linker complain. The methods it is complaining about are each intern...

Avoid range check on switch/case statement in gcc?

[Edit: It seems this is an issue on gcc versions prior to 4.4, I got confused because of a gcc bugzilla entry reporting it for 4.5 (latest). Sorry, I should've tested with more recent versions. Still, the problem is somewhat valid as most people don't run gcc 4.4+.] Is it possible to tell the compiler the variable used in a switch fits ...

C++0x Lambda Support in GCC for the iPhone

Can anyone tell me if C++ lambda expressions will be supported by GCC for the iPhone in the future? Obviously Apple have their custom 'block' support so I wondered what this may eventually mean in terms of portable C++0x code to the iPhone platform? ...

How can I add header files to gcc in mac os x 10.6

Hello, I want to build a static library that requires openssl for iPhone. It can't find include files from openssl. How should I tell the compiler where to look for those header files? Thanks. EDIT: I'm trying to build librtmp for iPhone, for arm not for simulator. Just to test something. Im not building it from xcode. I think i have fo...

How to measure x86 and x86-64 assembly commands execution time in processor cycles?

I want to write a bunch of optimizations for gcc using genetic algorithms. I need to measure execution time of an assembly functions for some stats and fit functions. The usual time measurement can't be used, 'cause it is influenced by the cache size. So I need a table where I can see something like this. command | operands | operands s...

GCC equivalent to VC's floating point model switch?

Does GCC have an equivalent compiler switch to VC's floating point model switch (/fp)? In particular, my application benefits from compiling with /fp:fast and precision is not a big deal, how should I compile it with GCC? ...

Aren't template class member functions compiled at instantiation?

I found a strange issue when porting my code from Visual Studio to gcc. The following code compiles fine in Visual Studio, but results in an error in gcc. namespace Baz { template <class T> class Foo { public: void Bar() { Baz::Print(); } }; void Print() { std::cout << "Hello, world!" << st...

Ensure compiler always use SSE sqrt instruction

I'm trying to get GCC (or clang) to consistently use the SSE instruction for sqrt instead of the math library function for a computationally intensive scientific application. I've tried a variety of GCCs on various 32 and 64 bit OS X and Linux systems. I'm making sure to enable sse with -mfpmath=sse (and -march=core2 to satisfy GCCs requ...

Embedding linker dependencies in an object file?

Let's say I have a source file, say helper.c, which gets compiled into an object library (helper.a). Now, this uses functionality from many system libraries, so currently when I want to link helper.a into an executable, I end up having to list all the dependencies: gcc main.c helper.a -o my_app -lrt -lpthreads ... What's the common ap...

Please explain the output for this code

int a=5; printf("%d %d %d\n",a++,a++,++a); Output on Gcc : 7 6 8 Can someone please explain the answer. I apologize if this question has been repeated but i wasn't able to find it. Thanks!! ...

My Cross Compiler Always Compiles the Same File

I'm testing to make sure that my cross compiler is working. When I compile hello world it seems to compile fine but when I change hello.cpp to the same program that loops 1000 times the elf file generated is exactly the same size. No matter what changes I make the file is always the same size and as far as I can tell, has the same cont...

"backslash not last character on line" when compiling gcc on windows.

I'm following this guide mostly to compile gcc on windows: http://www.aristeia.com/Misc/gcc4ForWindows.html The difference is that I am using msys 1.10 and trying to build gcc trunk from SVN. the source tree compiles fine on linux, however when I attempt to build on windows, i get the following error upon running the configure script. ...

How to modify the command XCode uses for creating the precompiled header?

Hi, I'm developing an iPhone application, and after making small changes to my code, when I tried to build I suddenly got the following build error when XCode tries to create precompiled header: i686-apple-darwin10-gcc-4.2.1: n: No such file or directory Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 fa...

what is the return type of typeof?

Hi, I want to provide the type of an element as parameter to an initialization of an array of pointers to element of an unknown types something like void* init(type t) void* array = malloc(sizeof_type(t)*10)); return array; } and later call for example init(typeof(int)) But I was not able to figure what is the return type ...

Standard c library headers on iPhone/iPod touch/iPad

I have an iPod touch and iPad with gcc installed on them. However, everytime I try to compile my programs they always fail. I am trying to write c programs for the terminal, not GUI. I am missing the standard c/c++ libraries (stdio.h, etc.). Can anyone tell me where I can find these libraries? ...

Expression intermediates in GCC (if that's what they're actually called)

I am trying to convert a math library written with VS so it will compile though GCC. The trouble is, I have a lot of overloaded operators that look like this: template<typename T> inline quaternion<T> operator+(quaternion<T> &a, quaternion<T> &b) {return quaternion<T>(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);} and so on. The problem is: Thes...