I'm writing a lot of code for the HiTech C compiler. I'm sure that my code would benefit from a static checker like splint, but splint itself trips up on some of HiTech's extensions, like cp0
and sfr
declarations. I can't just tell splint to skip the HiTech headers, though, because then it has no idea where most of my identifiers are from.
Does anyone know of a static checker that can cope with this?
Added: examples of extensions: Mostly it's just new type qualifiers and absolute addressing, eg.
extern volatile cp0 unsigned int cp0_Config @ __REGADDR(16,0);
extern volatile sfr unsigned long OC2R @ 0xBF803210;
(There's also the persistent
type qualifier.)
There are also the interrupt
and fast
qualifiers for functions:
void interrupt ExceptionHandler(void) @GENERAL_EXCEPTION
{
...
}
Added:
I finally got around to trying Doug Currie's approach below. I used a shell script with SED to strip out any trailing "... @ ...;" absolute positioning declarations, and ran split with
splint -D__32MX460F512L__ -Dsfr= -Dcp0= -Dmips32r2= -I ~/HiTechStripped mymodule.c
Depending on the module, splint complains:
< Location unknown >: Field name reused:
Code cannot be parsed. For help on parse errors, see splint -help
parseerrors. (Use -syntax to inhibit warning)
< Location unknown >: Previous use of
< Location unknown >: Previous use of
< Location unknown >: Previous use of
[this goes on for about 100 lines...]
On other modules, I get:
../../../../HiTechStripped/stdlib.h:140:39: mismatched parentheses in #if
Preprocessing error. (Use -preproc to inhibit warning)
It's wrong about this, as far as I can tell:
#if defined(_XA_) && sizeof(double) == 8
I think perhaps I should give up on the static checking. Thanks for the answers.