gcc

Errors while compiling Neko VM OS X

I'm trying to compile the Neko VM on Mac OS X (10.5.7) using GCC 4.01 and I'm completely stuck, because it stops while compiling saying: vm/threads.c:202: error: conflicting types for 'neko_thread_register' vm/neko_vm.h:37: error: previous declaration of 'neko_thread_register' was here I've tried googling this and some say it's becaus...

problems using the -ansi switch in MinGW 3.4.5

I was reading about the flags used in gcc, and read a reccommendation to use gcc -ansi -pedantic -Wall file1 [file2 [file3...]] -o output. For the quality of my code's sake, to keep it standard, and get all the warnings about it. Well, about compiling with -ansi... If I include <stdlib.h>, gcc gives me this error: In file included from...

gcc: Do I need -D_REENTRANT with pthreads?

On Linux (kernel 2.6.5) our build system calls gcc with -D_REENTRANT. Is this still required when using pthreads? How is it related to gcc -pthread option? I understand that I should use -pthread with pthreads, do I still need -D_REENTRANT? On a side note, is there any difference that you know off between the usage of REENTRANT betwee...

How do modern compilers use mmx/3dnow/sse instructions?

I've been reading up on the x86 instruction set extensions, and they only seem useful in some quite specific circumstances (eg HADDPD - (Horizontal-Add-Packed-Double) in SSE3). These require a certain register layout that needs to be either deliberately set up, or occur from the series of instructions before it. How often do general-purp...

Doubt regarding a tail optimized code under 'gdb'

Consider a tail recursive factorial implementation in C: #include <stdio.h> unsigned long long factorial(unsigned long long fact_so_far, unsigned long long count, unsigned long long max_count){ if (max_count==0 || max_count==1 || count >= max_count) return fact_so_far; else { printf("%llu %p \n", count, &factorial); ...

MSVC equivalent to '__builtin_return_address'

With msvc, is there an equivalent to gcc's "__builtin_return_address"? I'm looking to find the address of the calling function, 1 level deep. ...

gcc switches to enable analysis for warnings

In gcc, certain warnings require optimization to be enabled. For example: int foo() { int x; return x; } In order to detect the uninitialized variable, -O must be passed. $ gcc -W -Wall -c test.c $ gcc -W -Wall -c test.c -O test.c: In function ‘foo’: test.c:3: warning: ‘x’ is used uninitialized in this function However, thi...

Is log10f() not a part of standard math library?

I am having issues with usage of log10f(). I am compiling the program on Linux (2.6.28-11-generic) and using gcc (3.4.6). The following source compiles and prints 1.000000 on execution. #include <stdio.h> #include <math.h> int main() { printf("%f\n", log10f(10)); return 0; } while the below one doesn't and throws up link err...

What does the object code file ctr1.o do in the gcc compiler?

What does the obj file ctr1.o does in gcc compilier ?Why does the linker link this obj file whenever an executable is generated? ...

When to use -O2 flag for gcc?

If I use "-O2" flag, the performance improves, but the compilation time gets longer. How can I decide, whether to use it or not? Maybe O2 makes the most difference in some certain types of code (e.g. math calculations?), and I should use it only for those parts of the project? EDIT: I want to emphasize the fact that setting -O2 for ...

Cannot make VW34 (Oxford Active Vision Lab libraries) in Ubuntu 8.0.4

I'm trying to make a pretty obscure app called VW34 which is a computer vision library that uses openGL. I'm getting an error during make after most of the app compiles successfully "GeomObjects/point3d.cpp:88: error: ‘VW::Point3D VW::operator+(const VW::Point3D&, const VW::Point3D&)’ should have been declared inside ‘VW’" . Supposedly ...

Why C++ compiler (gcc) thinks function is `virtual' field?

I have a the following method definition in my class: virtual Calc* Compile( Evaluator* evaluator, ResolvedFunCall* fun_call, string* error); For some reason, GCC complains that: error: 'Compile' declared as a 'virtual' field Any ideas why it would believe Compile to be a field, instead of a method? ...

GCC --target triplet for HP-UX

I want to compile GCC and binutils which would produce 64bit executables. From GNU documents I've found out that it must look like ia64-*-hpux*. For ia64-hp-hpux11*, the default output type is 32bit: % file ./a.out ./a.out: ELF-32 executable object file - IA64 That is what I have: % uname -s -r -v -m HP-UX B.11.31 U ia64 ...

STL container assignment and const pointers.

This compiles: int* p1; const int* p2; p2 = p1; This does not: vector<int*> v1; vector<const int*> v2; v2 = v1; // Error! v2 = static_cast<vector<const int*> >(v1); // Error! What are the type equivalence rules for nested const pointers? I thought the conversion would be implicit. Besides, I'd rather not implement point-wise as...

Trouble understanding gcc's assembly output

While writing some C code, I decided to compile it to assembly and read it--I just sort of, do this from time to time--sort of an exercise to keep me thinking about what the machine is doing every time I write a statement in C. Anyways, I wrote these two lines in C asm(";move old_string[i] to new_string[x]"); new_string[x] = old_string...

Migrating from Winarm to Yagarto

Hi This question must apply to so few people... I am busy mrigrating my ARM C project from Winarm GCC 4.1.2 to Yagarto GCC 4.3.3. I did not expect any differences and both compile my project happily using the same makefile and .ld files. However while the Winarm version runs the Yagarto version doesn't. The processor is an Atmel AT9...

Warning about hiding member variables?

The following code snippet has a memory leak that I spent too much time chasing down. The problem is that inside Foo(), the local variable x_ hides the member variable x_. It's quite annoying too, because the compiler could have warned me about it. Is there a flag in GCC for such a warning? (For the curious: I have arrived at the bugg...

why is char's sign-ness not defined in C?

The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char. And indeed gcc define that accord...

Merge multiple .so shared libraries

Say I have a.so and b.so. Can I produce c.so as a single shared library with all the functions exported by a and b, of course resolving all intra-dependencies (i.e. all functions of b.so called by a.so and the other way around)? I tried gcc -shared -Wl,soname,c.so -o c.so a.so b.so but it doesn't work. Same goes if I archive a.o and ...

selectively removing warning

This piece of code : Int32 status; printf("status : %x", status) gives me the following warning : jpegthread.c:157: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'Int32' I know I can get read of it by casting the type, but is it possible with a gcc CFLAG to get rid of that particular type of warning, and...