I've recently learned how to program simple character drivers and while playing around with the code I noticed that I get a lot of the following GCC warnings thrown for my C99 code:
warning: ISO C90 forbids mixed declarations and code
I assume this is because the main Linux kernel Makefile is set to compile using a non-C99 standard. I searched around I found this answer here on stackoverflow: How to use make and compile as C99?
So I naturally tried the following in my Makefile:
ccflags-y := -std=gnu99
Unfortunately this didn't silence the GCC warnings. I checked the verbose output of make
and verified that GCC is indeed executed with the -std=gnu99
tacked on at the end; so I'm a bit confused.
How do I properly compile a Linux kernel module using the -std=gnu99
option?
EDIT:
I noticed the GCC output shows this option: -Wdeclaration-after-statement
. Is this why I am getting the warnings even with the -std=gnu99
option?