Pedantic raising error when linking PAPI

I am trying to build some project that uses the PAPI library, in an Arch Linux x86_64.

For simplicity sake, I reproduced the things that I don't understand in these two files:


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

int main() {


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

int main() {

When compiling it (to an object file) I get the following:

(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

Why does the -pedantic flag raises errors, but not warnings?(2)

Why does the 3rd run does not raises nothing (just by switching the includes)?


-pedantic enables full compatibility with C++ Standard and disables gcc extensions. So stuff which reported in this mode usually is an error.

As for why changing order of includes changes the error, I can only guess. My best guess is that string.h defines certain macros which are checked in papi.h. Looking in it's source code might help.

Need Your Help

Which zlib functions are compatible with WinZip?

c algorithm compression gzip

Using deflate() I was unable to open the zipped file using WinZip. Are the gz() the only ones compatible with WinZip? or is there some sort of mode I must call deflate() with?

How to access objects from AppDelegate without affecting memory management?

ios objective-c cocoa-touch cocoa

I have several view controller objects each can take in some user inputs from UITextField, save inputs to mutable arrays and display in a UITableView.