2016-03-22 11 views
2

Arch Linux x86_64でPAPI 5.4.3.0ライブラリを使用するプロジェクトを作成しようとしています。 PAPIをリンクするときに脚立エラーが発生する

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

int main() { 
} 
B.cpp

A.cpp

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

int main() { 
} 

:簡単のために

は、私はこれらの2つのファイルに理解していないものを再現しました

(オブジェクトファイルに)コンパイルすると、次のようになります。

(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)

なぜ第三の実行が(ちょうど含んで切り替えることで)何を提起しませんでしょうか?

答えて

1

-pedanticは、C++標準と完全に互換性があり、gcc拡張機能を無効にします。したがって、このモードで報告されるものは通常エラーです。

なぜincludeの順序を変更するとエラーが変わるのか、私は推測できます。私の推測では、string.hはpapi.hでチェックされている特定のマクロを定義しています。それを見るとソースコードが役立つかもしれません。

+0

フラグ* -pedantic-errors *は、エラーではなく、ほんのわずかである場合には、1と扱われるようにすることです。 – yZaph

+0

@yZaph、はい、正しい。 – SergeyA

関連する問題