Suppression of "superfluous", "errors" in GCC, when -pedantic is included

I create my program with a flag -pedantic, which causes an error extra ';'(due to inconsistency of the third-party header using several macros, the error does not appear when it is -pedanticturned off). I really don't like disconnecting -pedantic, and I also don't want to edit the title. Is there any way to suppress this exact error? Like a compiler switch -Wno-annoying-semicolon-erroror something else?

+5
source share
3 answers

The workaround is removal -pedantic. In this case, nothing will work.

+1
source

-isystem, -I include paths, GCC .

, , .

+2

You can suppress pedantic warnings for external headers as follows:

//save compiler switches
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"

//Bad headers with problem goes here
#include <ros/ros.h>
#include <sensor_msgs/LaserScan.h>

//restore compiler switches
#pragma GCC diagnostic pop
+2
source

All Articles