本文介绍了GCC -O2与无原因的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在编译包含打开(文件名,O_RDONLY)文件;
没有 -O2
标记一切都很好。但是,当 -O2
打开时,我得到:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:在功能上开放:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:44:7:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:45:26:错误:调用与属性错误声明__open_too_many_args:打开可称为无论是与2个或3个参数,而不是更多
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:42:1:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:60:3:错误:无效使用'__builtin_va_arg_pack()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:在功能open64:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:76:7:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:77:28:错误:调用与属性错误声明__open64_too_many_args':open64可以被称为无论是与2个或3个参数,而不是更多
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:74:1:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:92:3:错误:无效使用'__builtin_va_arg_pack()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:在函数'openat':
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:120:7:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:121:28:错误:调用与属性错误声明__openat_too_many_args':openat可以被称为无论是与3个或4个参数,而不是更多
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:118:1:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:136:3:错误:无效使用'__builtin_va_arg_pack()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:在函数'openat64:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:154:7:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:155:30:错误:调用与属性错误声明__openat64_too_many_args':openat64可以被称为无论是与3个或4个参数,而不是更多
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:152:1:错误:无效使用'__builtin_va_arg_pack_len()
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:170:3:错误:无效使用'__builtin_va_arg_pack()
在哪里是什么问题?它的混合 C / C ++
项目,但是这是在 C
部分。 GCC 4.6.1,内核3.0.0
编辑:原来,commeting掉那些行给出了另一个像错误的类型:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:在功能的sprintf:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:34:3:错误:无效使用'__builtin_va_arg_pack()
解决方案
试着用 -fno-内建
编译。如果修复它,然后你显然某种问题,但它可能不是你的源。
When compiling file containing open("FILENAME", O_RDONLY);
without -O2
flag everything is fine. But when -O2
is turned on I get:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h: In function ‘open’:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:44:7: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:45:26: error: call to ‘__open_too_many_args’ declared with attribute error: open can be called either with 2 or 3 arguments, not more
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:42:1: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:60:3: error: invalid use of ‘__builtin_va_arg_pack ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h: In function ‘open64’:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:76:7: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:77:28: error: call to ‘__open64_too_many_args’ declared with attribute error: open64 can be called either with 2 or 3 arguments, not more
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:74:1: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:92:3: error: invalid use of ‘__builtin_va_arg_pack ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h: In function ‘openat’:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:120:7: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:121:28: error: call to ‘__openat_too_many_args’ declared with attribute error: openat can be called either with 3 or 4 arguments, not more
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:118:1: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:136:3: error: invalid use of ‘__builtin_va_arg_pack ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h: In function ‘openat64’:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:154:7: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:155:30: error: call to ‘__openat64_too_many_args’ declared with attribute error: openat64 can be called either with 3 or 4 arguments, not more
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:152:1: error: invalid use of ‘__builtin_va_arg_pack_len ()’
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:170:3: error: invalid use of ‘__builtin_va_arg_pack ()’
Where can be the problem? It's mixed C/C++
project but this is in the C
part. gcc 4.6.1, kernel 3.0.0
Edit: It turns out that commeting out those line gives another "type" of errors like:
/usr/include/x86_64-linux-gnu/bits/stdio2.h: In function ‘sprintf’:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:34:3: error: invalid use of ‘__builtin_va_arg_pack ()’
解决方案
Try compiling with -fno-builtins
. If that fixes it then you've obviously got some sort of problem, but it's probably not in your source.
这篇关于GCC -O2与无原因的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!