7

我有一个长双场的工会。

我初始化一个字段并将其传递给一个函数。

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

编译此代码时,我得到:

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

似乎与这里提到的变化有关:http: //gcc.gnu.org/gcc-4.4/changes.html

这是否意味着我不能通过一个具有 long double 作为字段的联合?为什么是这样?我该如何解决这个问题,因为我想使用 long double 来存储大值。

4

2 回答 2

9

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

于 2013-05-30T08:07:01.267 回答
0

编译时尝试使用选项 -msse2 或 -march=k8

于 2013-05-30T08:10:43.347 回答