I've recently enabled -pedantic
option on gcc and now I've got about two or three pages of "ISO C90 forbids mixed declaration and code" warnings.
My goal with this project is to be able to deploy it on any mainstream system with a c compiler, so I realize it wouldn't be wise to assume that C99 will be supported everywhere, but is it even worth my time to address these warnings?
Are there still systems out there with c compilers that don't support mixed declaration and code?
Well, was/is it your intent to write your code in C89/90 or in C99?
Since this is the only warning you seem to be concerned about, apparently your code was actually written in C89/90. If it is indeed so and you plan to stick with C89/90, then I'd stick to strict C89/90 and move all declarations to the beginning of the block.
If, on the other hand, you are willing and planning to switch to C99, then "misplaced" declarations are no longer an issue. Then your main concern becomes the platform/compiler support. MS Visual Studio C compilers are C89/90 compilers. Is this a problem? (Considering that GCC is available on Windows platforms).
If you want to be -pedantic
about the C99 standard add the option -std=c99
.
Personally I like the older unmixed style because it makes it easier to audit visually what types of memory the function is using and decide what might need free()-ing before returning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With