Search code examples
cgccsyntax-errorgcc-warning

Is there any way to suppress errors about missing header files in GCC?


I need to check 2 million C source files for a research project for simple syntax errors like missing (semicolons, parenthesis, ...). Each file is a function without main() and header files. With the help of GCC, I have used the following command:

gcc -c -fsyntax-only -w file.c

My script is doing the job, but the only problem is that almost more than 95% of errors are related to missing header files. I tried to add some of these header files to each function, but the number of these header files seems endless.

Is there any way to suppress errors about missing header files?

Does GCC have a special Flag that I can use for my purpose?

A sample of errors that are related to header files:

error: unknown type name ‘ioreq_t’
error: unknown type name ‘SH7750State’
error: unknown type name ‘int64_t’
error: unknown type name ‘AVCodecContext’
error: unknown type name ‘BlockDriverState’
error: unknown type name ‘PXA2xxLCDState’

Also, I appreciate any other solution besides using GCC.


Solution

  • As workaround, you might create one header which includes all the missing #include and use -include to force that inclusion on top of examined files. So you don't edit all files:

    gcc -include "workaround.h" -c -fsyntax-only -w file.c