Do you know how I can make splint ignore where I declare my variables?
I know that in old school you are invited to declare variables right from the beginning of each function, but since I am a bad person, I like to declare things next to where I use them. A good example is setting int i; right before for (i = 0; ...).
Take a very simple example
#include <stdio.h> int main() { printf("Hello splint test\n"); int i; for(i=5;i>0;i--) { printf("%2d...\n",i); } return 0; }
Here splint and most older c compilers would like to move int i; up one line, or put {} around the declaration and for loop.
And now, to the question, how to disable this check? But keep the other checks that are good?
Thanks Johan
Note 1: I already use gcc warnings (see below) as the first line of defense, and valgrind as the second. But I'm thinking of adding a tire to the list of things that could control my stupidity ;-) But this check is just annoying,
The gcc warnings I use are: -Wall -W -Wextra -Wconversion -Wshadow -Wcast-qual -Wwrite-strings -Werror
Note 2: I am aware of potential tolerance problems that may result from such poor behavior. But I feel this enhances readability, since you don't have to jump up and down to search for this type. Ads are more valuable (and we can discuss this in another thread).
Update : A little more information, I put the above code in a file called main.c. The Ubuntu 8.04 platform used and gvim as an editor, and this is the output from the bus when I run it:
splint +gnuextensions main.c Splint 3.1.1 --- 03 Nov 2006 Command Line: Setting +gnuextensions redundant with current value main.c:8:8: Parse Error. (For help on parse errors, see splint -help parseerrors.)
And this opens up two more questions that I had not thought of before.
"redundant with current value", what is the current value?
Why is this an analysis error and not a warning?
Update:: It is possible to plan a bus to support this problem. I have not tried this yet, but still, but I think this is the solution.