Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the ABI of passing union with long double has changed in GCC 4.4

Tags:

c

I have an union with a long double field.

I initialize a field and pass it to a function.

my_union foo;
foo.long_double = 10.10;
bar = baz(foo);

When compiling this code I get:

the ABI of passing union with long double has changed in GCC 4.4

Seem to be related to the changes mentioned here: http://gcc.gnu.org/gcc-4.4/changes.html

Does this mean I cannot pass an union having a long double as field? Why is this? And how can I solve this since I wanna use long double for storing large values.

like image 888
jluu Avatar asked May 30 '13 08:05

jluu


1 Answers

What this means is the resulting code is not binary compatible with code compiled with previous versions of GCC, so if you're passing it between libraries between binaries compiled with the current version and a previous version, it's not going to work. (see comments for info about memory layout for network transport and saving to files)

As you can see from the link you provided:

Code built with previous versions of GCC that uses any of these is not compatible with code built with GCC 4.4.0 or later.

Either don't do it, or make sure all your code that uses unions mentioned in the changelog are compiled on the same compiler version (or technically ABI).

http://en.wikipedia.org/wiki/Application_binary_interface

like image 143
xaxxon Avatar answered Oct 04 '22 01:10

xaxxon