The following minimal test case int a(); generates no warning when -Wold-style-declaration -std=c11 is specified. It is expected that a warning should be produced. The manual at https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html says: -Wold-style-declaration Warn for obsolescent usages, according to the C Standard, in a declaration The C11 draft standard says: 6.11.6 Function declarators The use of function declarators with empty parentheses (not prototype- format parameter type declarators) is an obsolescent feature. === Information about the compiler: * output of gcc -v Using built-in specs. COLLECT_GCC=gcc-5.2.0 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/5.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-5.2.0/work/gcc-5.2.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/5.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/5.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/include/g++-v5 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/5.2.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 5.2.0 p1.0, pie-0.6.3' --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --enable-lto --without-isl --enable-libsanitizer Thread model: posix gcc version 5.2.0 (Gentoo 5.2.0 p1.0, pie-0.6.3)
I think -Wstrict-prototypes does what you're looking for here: $ /usr/local/bin/gcc -Wold-style-declaration -Wold-style-definition -Wstrict-prototypes -Wmissing-parameter-type -Wmissing-prototypes -std=c11 -pedantic -c pr68344.c pr68344.c:1:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes] int a(); ^
Indeed. I somehow missed that option. It probably would be logical for -Wold-style-declaration to imply -Wstrict-prototypes, but this is a minor issue.
Resolved.