I'm using the embedded-system XC8 C compiler (for PIC microprocessors). The following is allowed:
bit foo(){
//...
}
but being non-standard C, the Splint static analyser gives the following error:
Parse Error: Non-function declaration: bit : "--------------------------------------" int.
And the file/line of the error is the function prototype in the respective .h file.
How can I fix this so Splint can analyse the rest of the file(s)? I think there might be two ways:
I think I remember seeing a flag which can be passed to Splint via CLI which tells it to substitute a given non-standard type to a standard type (e.g. bit to unsigned char) but I can't seem to find it at all now!
Also, perhaps there is an alternative way to write the c code that satisfies ANSI-C requirements while also still allowing XC8 to interpret the return type as
bit
?
Progress:
I found the following on a forum, but I can't find information on how to use the -D flag in the manual:
To ignore a keyword, add -Dnonstandardkeyword= to make the preprocessor eliminate it
And
use -Dspecialtype=int to make a custom type parse as an int.
If there's no option for the analysis program to do the substitution, you can of course do it using the preprocessor.
Have something like:
in e.g. a header that you make sure is included everywhere,
enter code here
and make sure you define the pre-processor symbolRUNNING_SPLINT
when Splint sees the code. It has a-D
flag for this.It was in the FAQ:
http://www.splint.org/faq.html
To quote it: