c++ - typedef float _Float32的声明说明符中的两个或多个数据类型;

标签 c++ c gcc

我正在从KEIL OS移植相当老的C(和一点C++)代码基础到Linux 32位。

当使用gcc / g++ 6.3到6.5进行编译时,它工作正常,当尝试对gcc> 7.0进行同样的操作(在ubuntu 18.04上用7.3和8.2测试)时,出现编译错误:

/usr/include/bits/floatn-common.h:207:15: error: two or more data types in declaration specifiers
 typedef float _Float32;
               ^~~~~~~~
/usr/include/bits/floatn-common.h:244:16: error: two or more data types in declaration specifiers
 typedef double _Float64;
                ^~~~~~~~
/usr/include/bits/floatn-common.h:261:16: error: two or more data types in declaration specifiers
 typedef double _Float32x;
                ^~~~~~~~~
/usr/include/bits/floatn-common.h:278:21: error: two or more data types in declaration specifiers
 typedef long double _Float64x;

编译器头文件(/usr/include/bits/floatn-common.h:261:16)文件包含以下部分:

# if __HAVE_FLOAT32

#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
typedef float _Float32;
#  endif

#  if !__GNUC_PREREQ (7, 0)
#   define __builtin_huge_valf32() (__builtin_huge_valf ())
#   define __builtin_inff32() (__builtin_inff ())
#   define __builtin_nanf32(x) (__builtin_nanf (x))
#   define __builtin_nansf32(x) (__builtin_nansf (x))
#  endif

# endif

告诉我这只与gcc > 7.0相关

与该错误有关的大多数问题都缺少“;”在结构或做类似的事情

void int myFunction(void){}

尽管我认为不是这种情况,因为它出现在不同的编译单元中,并且可以与gcc/g++的早期版本一起使用
using glibc version 2.2 7

我的问题:是否可以禁用此新的编译器功能,或者最终从社区中提示从哪里开始搜索

最佳答案

发现了问题:

在源代码中的某个地方有一个

#undef __GNUC__

这是由损坏的代码生成工具产生的...

这样一来,math.h或wchar.h的所有包含都被破坏了...

关于c++ - typedef float _Float32的声明说明符中的两个或多个数据类型;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54843947/

相关文章:

c++ - 使用 VS2019 为 Linux 编译我的 C++ exe

c++ - 声明 C++ 中的类型太多

c++ - 从 Vector3f 转换为 Matrix4f

C 语言中的级联和嵌套 if 语句

objective-c - Cordova 插件与 C 库通信

c++ - 使用ssh框架加载共享库

c++ - 如何将thread::id 发送给PostThreadMessage?

c - 空闲内存用于 C 中的结构但失败(代码来自 C Primer Plus 第 6 版)

c++ - c 风格的类型转换和 operator()

c++ - is_constructible 和 is_destructible 不受 friend 声明的影响