【问题标题】:Pedantic raising error when linking PAPI链接 PAPI 时出现迂腐错误
【发布时间】:2016-03-22 20:07:24
【问题描述】:

我正在尝试在 Arch Linux x86_64 中构建一些使用 PAPI 5.4.3.0 库的项目。

为了简单起见,我将这两个文件中我看不懂的东西复现了:

A.cpp

#include "string.h"
#include "papi.h"

int main() {
} 

B.cpp

#include "papi.h"
#include "string.h"

int main() {
} 

编译它(到目标文件)时,我得到以下信息:

(1)$ g++ A.cpp -c -std=c++11
(2)$ g++ A.cpp -c -std=c++11 -pedantic
In file included from b.cpp:2:0:
/usr/include/papi.h:1021:27: error: declaration of ‘int ffsll(long long int)’ has a different exception specifier
int ffsll(long long lli); //required for --with-ffsll and used in extras.c/papi.c
                       ^
In file included from A.cpp:1:0:
/usr/include/string.h:524:26: error: from previous declaration ‘int ffsll(long long int) throw ()’
__extension__ extern int ffsll (long long int __ll)

(3)$ g++ B.cpp -c -std=c++11 -pedantic

为什么 -pedantic 标志会引发错误,而不是警告?(2)

为什么第 3 次运行没有引发任何问题(仅通过切换包含)?

【问题讨论】:

    标签: c++ papi gcc-pedantic


    【解决方案1】:

    -pedantic 启用与 C++ 标准的完全兼容并禁用 gcc 扩展。所以在这种模式下报告的东西通常是错误的。

    至于为什么改变包含的顺序会改变错误,我只能猜测。我最好的猜测是 string.h 定义了在 papi.h 中检查的某些宏。查看它的源代码可能会有所帮助。

    【讨论】:

    • 所以标志 -pedantic-errors 只是为了确保当它不是一个错误时,它只是少数几个,它被视为一个?
    猜你喜欢
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 2013-01-22
    • 1970-01-01
    • 2014-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多