gcc

Does changing the order of class private data members breaks ABI

I have a class with number of private data members (some of them static), accessed by virtual and non-virtual member functions. There's no inline functions and no friend classes. class A { int number; string str; static const int static_const_number; bool b; public: A(); virtual ~A(); public: // got virtual a...

GCCs atomic builtins - Which processors are supported

This document says: Not all operations are supported by all target processors. Does anybody know, for which processor which operation is supported? ...

Can I upgrade Xcode to support a newer version of GCC to learn C++0x?

I would like to jump in learn C++0x, which has matured to a level I'm happy with. Xcode on Snow Leopard 10.6 is currently at GCC 4.2.1, and the new features I'd like to try, like std::shared_ptr, lambdas, auto, null pointer constant, unicode string literals, and other bits and pieces, require at least 4.3 (I believe). Ideally I'd use X...

Compile time float packing/punning

I'm writing C for the PIC32MX, compiled with Microchip's PIC32 C compiler (based on GCC 3.4). Added The standard I'm following is GNU99 (C99 with GNU extensions, compiler flag -std=gnu99) My problem is this: I have some reprogrammable numeric data that is stored either on EEPROM or in the program flash of the chip. This means that when...

GCC how to block system calls within a program?

Does anyone tell me how to block some specific system calls within a program, please? I am building a system which takes a piece of C source code, compiles it with gcc and runs it. For security reasons, I need to prevent the compiled program from calling some system calls. Is there any way to do it, from the source code level (e.g. strip...

MySql UDF using shared library won't load

I am attempting to create a mysql UDF which will match a fingerprint using Digital Persona's free linux SDK library. I have written a trivial UDF as a learning experience which worked fine. However, when I added a dependency to Digital Persona's shared object I can no longer get MySql to load my UDF. I added includes to DP's headers a...

Can I mix static and shared-object libraries when linking?

I have a C project that produces ten executables, all of which I would like to be linked in statically. The problem I am facing is that one of these executables uses a 3rd-party library of which only the shared-object version is available. If I pass the -static flag to gcc, ld will error saying it can't find the library in question (I p...

"variable tracking" is eating my compile time!

I have an auto-generated file which looks something like this... static void do_SomeFunc1(void* parameter) { // Do stuff. } // Continues on for another 4000 functions... void dispatch(int id, void* parameter) { switch(id) { case ::SomeClass1::id: return do_SomeFunc1(parameter); case ::SomeClass2::id: return...

Building elf within Eclipse within Windows

Hey guys, I'm having trouble building an Elf file within Eclipse within Windows. It seems that everytime I build, a PE / portable executable for windows is created. I've gone into the Binary Parser section and checked Elf Parser while making sure that everything else is unchecked. However, I continue to end up with a PE which I cannot r...

Freestanding ARM C++ Code - empty .ctors section

I'm writing C++ code to run in a freestanding environment (basically an ARM board). It's been going well except I've run into a stumbling block - global static constructors. To my understanding the .ctors section contains a list of addresses to each static constructor, and my code simply needs to iterate this list and make calls to each...

No warning from gcc when function definition in linked source different from function prototype in header

Hi, I had a problem with a part of my code, which after some iterations seemed to read NaN as value of a double of a struct. I think I found the error, but am still wondering why gcc (version 3.2.3 on a embedded Linux with busybox) did not warn me. Here are the important parts of the code: A c file and its header for functions to acqui...

syscall from within GCC inline assembly

is it possible to write a single character using a syscall from within an inline assembly block? if so, how? it should look "something" like this: __asm__ __volatile__ ( " movl $1, %%edx \n\t" " movl $80, %%ecx \n\t" " movl $0, %%ebx \n\t" ...

GNU C++ how to check when -std=c++0x is in effect?

My system compiler (gcc42) works fine with the TR1 features that I want, but trying to support newer compiler versions other than the systems, trying to accessing TR1 headers an #error demanding the -std=c++0x option because of how it interfaces with library or some hub bub like that. /usr/local/lib/gcc45/include/c++/bits/c++0x_warning....

gcc -Wshadow is too strict?

In the following example: class A { int len(); void setLen(int len) { len_ = len; } // warning at this line int len_; }; gcc with -Wshadow issue a warning: main.cpp:4: warning: declaration of `len' shadows a member of `this' function len and integer len are of different type. Why the warning? Update I see there's a w...

gcc, strict-aliasing, and horror stories

In http://stackoverflow.com/questions/2906365/gcc-strict-aliasing-and-casting-through-a-union I asked whether anyone had encountered problems with union punning through pointers. So far, the answer seems to be No. This question is broader: do you have any horror stories about gcc and strict-aliasing? Background: Quoting from AndreyT's...

Is profile guided optimization possible with shared libraries in gcc?

Hi, I recently rolled out a new Toolchain on Linux, with gcc 4.5.0 and binutils 2.20 with gold. Now I was curious about this new thing PGO. While it's clear how it works with executables, I've not been able to find an answer on shared libraries. I found two unanswered posts on the gcc mailing list via google, that's all. So here's what...

How to change the default behavior of overwriting when GCC -fstack-protector-all is set?

I would like to use the GCC -fstack-protector-all option on release mode. The main issue is that when there is an override a core is built. I would like to plug something that will just dump the stack and let the program continue. Is there a way to do that? ...

GCC compile time division error

Can someone explain this behaviour? test.c: #include <stdio.h> int main(void) { printf("%d, %d\n", (int) (300.6000/0.05000), (int) (300.65000/0.05000)); printf("%f, %f\n", (300.6000/0.05000), (300.65000/0.05000)); return 0; } $ gcc test.c $ ./a.out 6012, 6012 6012.000000, 6013.000000 I checked the assembly code and it...

GCC doesn't like C++ style casts with spaces

I am porting some C++ code to GCC, and apperantly it isn't happy with C++ style casting when sapces are involved, as in unsigned int(-1), long long(ShortVar) etc... It gives an error: expected primary-expression before 'long'. Is there any way to make peace with GCC without going over each one of those and rewrite in c-style? ...

GCC, functions, and pointer arguments, warning behaviour

I've recently updated to a testing distribution, which is now using GCC 4.4.3. Now I've set everything up, I've returned to coding and have built my project and I get one of these horrible messages: *** glibc detected *** ./boxyseq: free(): invalid pointer: 0x0000000001d873e8 *** I absolutely know what is wrong here, but was rather con...