gcc

What's the most efficient way to multiply 4 floats by 4 floats using SSE ?

I currently have the following code: float a[4] = { 10, 20, 30, 40 }; float b[4] = { 0.1, 0.1, 0.1, 0.1 }; asm volatile("movups (%0), %%xmm0\n\t" "mulps (%1), %%xmm0\n\t" "movups %%xmm0, (%1)" :: "r" (a), "r" (b)); I have first of all a few questions: (1) if i WERE to a...

How to use a different STL with g++

Hello, I want to use a different STL with g++ instead of its default libstdc++. What is the easiest way to do this? I found -nostdinc++ flag which inhibits g++ from looking for its STL headers but this is only a compile time thing. It will still make g++ link against its own STL. So I need to find a way to inhibit the linking. Thanks...

(C++ and gcc) error: expected constructor, destructor, or type conversion before 'inline'

I have a header file with some inline template methods. I added a class declaration to it (just a couple of static methods...it's more of a namespace than a class), and I started getting this compilation error, in a file that uses that new class. There are several other files that include the same .h file that still compile without com...

Does link line order for supc++ really matter?

Hello, This is a follow up to an earlier question - http://stackoverflow.com/questions/1227615/how-to-use-a-different-stl-with-g I can now get my code to build while using a different STL. However, I still need to link -lsupc++ (along with said different STL) I see anecodal references that -lsupc++ should be the last library on the ...

Why do I get a warning everytime I use malloc?

If I use malloc in my code: int *x = malloc(sizeof(int)); I get this warning from gcc: new.c:7: warning: implicit declaration of function ‘malloc’ new.c:7: warning: incompatible implicit declaration of built-in function ‘malloc’ I'm new to C. Am I doing something wrong? ...

QT cross-platform issue: compiles fine on windows, linker error on linux

I have some QT code called "GUI". Via Qt Creator, I am able to compile (using gcc) it without any complaints on Windows. However, when I try to compile it (again using gcc via Qt Creator) on Linux, I get a linker error "collect2: ld returned 1 exit status". The only non-QT library that I use is the STL's vector library. (To make matt...

How can I get perl on my iPhone 3GS?

Hello I'm trying to get a regular C compiling environment on an iPhone 3GS running OS3.0 . So far I have been unsuccessful in finding a suitable gcc (i mean the complete suite, gcc+headers+libc+whatever else it needs) for it. Does anyone know if it is (yet) available and where ? If not yet, is there any tutorial on the net on how to ...

SCons: GCC Ignoring -c

Hi, I'm using a MinGW-based GCC cross-compiler to compile a project which uses SCons as its build system. The Python is a native 2.6.2 version, not specifically compiled for MinGW (or Cygwin). However, I am running into a problem with the build: F:/pedigree/compilers/bin/i686-elf-gcc -o build\src\user\applications\apptest\ma in.obj -...

Unexpected EXC_BAD_ACCESS in Objective-C

Hi, I have the following method: -(void)testAPIModule { self.requests = [NSMutableArray array]; NSLog(@"making arrays"); /*(A)*/ id array1 = [NSArray arrayWithObjects:[NSNumber numberWithInt:1], [NSNumber numberWithFloat:2], nil]; /*(B)*/ id array2 = [NSArray arrayWithObjects:[NSNumber numberWithInt:4], [NSNumber numberWithInt:5]];...

Are compund statements (blocks) surrounded by parens expressions in ANSI C?

Browsing the Linux kernel sources I found some piece of code where a block of statements surrounded by parenthesis is treated as a expression a la lisp (or ML), that is, an expression which value is the value of the last statement. For example: int a = ({ int i; int t = 1; for (i = 2; i<5; i++) { t*=i; } t; ...

Help with linker failer: .gnu.linkonce.t...

I'm having trouble linking a shared library using gcc 3.2.3 with binutils 2.18. When I try to link the library I get the following error: .gnu.linkonce.t_... referenced in section .rodata: defined in discarded section .gnu.linkonce.t... I've done a fair amount of googling on this and most places seem to indicate it is a regression intr...

Why doesn't a derived template class have access to a base template class

Consider: template <typename T> class Base { public: static const bool ZEROFILL = true; static const bool NO_ZEROFILL = false; } template <typename T> class Derived : public Base<T> { public: Derived( bool initZero = NO_ZEROFILL ); // NO_ZEROFILL is not visible ~Derived(); } I can't compile...

Compiling Small Gcc Project on Windows Using MinGW

Hello, so I've been programming in C++ for almost 2 years now, and the whole while I've had the pleasure of using an IDE (VS) with lovely project settings and automatic linking and the like. I've always stayed away from any external libraries which required me to compile via makefiles, or at least the ones which were meant for linux envi...

Manipulating the search path for include files

My development environment is such that I have some_header.h in /usr/include and in /another/directory. /another/directory contains some header files I need to include in my program, but I want to use some_header.h from /usr/include. When I use gcc ... -I/another/directory gcc uses /another/directory/some_header.h. If I use gcc ...

How to use "make" to use 64 bit libs because of ELFCLASS64 error

How can I use configure and make tools to specify to use 64 bit libraries ? I thought it was automatic, but I get wrong ELF Class I'm trying to compile xdebug for ubuntu 64 for use with lampp (xampp for linux) ./lampp start Failed loading /opt/lampp/lib/php/extensions/xdebug.so: /opt/lampp/lib/php/extensions/xdebug.so: wrong ELF c...

Constructor initialization-list evaluation order

I have a constructor that takes some arguments. I had assumed that they were constructed in the order listed, but in one case it appears they were being constructed in reverse resulting in an abort. When I reversed the arguments the program stopped aborting. This is an example of the syntax I'm using. The thing is, a_ needs to be init...

C++ Operator overloading - casting from class

While porting Windows code to Linux, I encountered the following error message with GCC 4.2.3. (Yes, I'm aware that it's a slight old version, but I can't easily upgrade.) main.cpp:16: error: call of overloaded ‘list(MyClass&)’ is ambiguous /usr/include/c++/4.2/bits/stl_list.h:495: note: candidates are: std::list<_Tp, _Alloc>::list(cons...

gcc-4.2 failed with exit code 1 iphone

Hi, I've seen this error with different variations on discussion forums but being a non programmer I'm not sure how to progress this. Basically I have code which I found to help me with changing the background colors of cells on a grouped uitableview. The code introduced a line as such: CGContextAddArcToPoint(c, minx, miny, midx, miny...

Get GCC to preserve an SSE register throughout a function that uses inline asm

I'm writing a program in C that needs to do some fast math calculations. I'm using inline SSE assembly instructions to get some SIMD action (using packed double precision floating point numbers). I'm compiling using GCC on Linux. I'm in a situation where I need to loop over some data, and I use a constant factor in my calculations. I'd ...

Passing a gcc flag through makefile

Hi, I am trying to build a pass using llvm and I have finished building llvm and its associated components. However, when I run make after following all the steps to build a pass including the makefile, I get the following error: *relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile wit...