What kind of warnings is -isystem in gcc supposed to ignore?

140 Views Asked by At

Several blogs, tutorials and GCC's documentation have lead me to believe -isystem can be used to ignore warnings in header files. A simple test suggests otherwise.

#include <liburing.h>

int main() { return 0; }

Compiled as:

~ > gcc -isystem /opt/extras/include -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -std=c89 -Wpedantic -pedantic-errors test.c

/opt/extras/include/liburing.h:140:14: error: expected ';' before 'void'
  140 | static inline void io_uring_cq_advance(struct io_uring *ring,
      |              ^~~~~
      |              ;
In file included from /opt/extras/include/liburing/barrier.h:56,
                 from /opt/extras/include/liburing.h:16,
                 from test.c:1:
/opt/extras/include/liburing.h: In function 'io_uring_cq_advance':
/opt/extras/include/liburing.h:150:3: error: unknown type name 'typeof'
  150 |   io_uring_smp_store_release(cq->khead, *cq->khead + nr);

The documentation for -isystem and System-Headers isn't exactly clear about what kind of warnings in system headers it is supposed to ignore. Why does GCC not ignore pendantic warnings/errors in 3rd party headers which is explictly marked as -isystem?

To put some perspective, the coding guidelines I'm following enforces strict ANSI C for "business" reasons, which I cannot change. For now, I've edited that header by replacing inline to __inline and typeof to __typeof which seems to work.

2

There are 2 best solutions below

4
dbush On

The special treatment given to system header files is to ignore any warnings in the header, as mentioned in the second link you gave:

All warnings, other than those generated by ‘#warning’ (see Diagnostics), are suppressed while GCC is processing a system header

The problem is that you're getting errors, not warnings. The header apparently uses features that are not allowed in strictly conforming C89.

That means you're stuck modifying the header to use compiler-specific extensions, however I wouldn't depend on doing such things. This would be a good case to push for an exception to the guidelines since the library in question doesn't strictly conform to C89.

1
Hello World On

Can you check the latest version of liburing.h https://github.com/axboe/liburing/blob/master/src/include/liburing.h

This seems to declare the io_uring_cq_advance() differently.