I believe I've got PC-Lint installed OK as per the Keil instructions, but on Linting my source it seems all the system sfr & sbits are being flagged up, eg :
"Error 40: Undeclared identifier 'ADCON'"
along with TMOD, TH0, TL0, EAL, ET0, P1, P3, P4...
These are resolved for the compiler by a
#include <reg515c.h>
Keil include file with SBIT and SFR definitions in. Lint doesn't seem to be seeing them though.
Does anyone have any pointers for me for how to fix this?
Indeed, configuring PC-Lint through the uV3->tools->setup PClint dialogue box. I had got the following in there :
.\ .\common\ C:\Keil\C51\INC\ C:\Keil\C51\INC\Infineon\
More experimenting; removing my project local copy of the reg515c.h library header, reverting the C source to #include it as <>, and changing the first two project include paths to be the full directory names pathed from C:\ down, rather then the relative ones, and Lint is now parsing all the include files correctly. When I've finished the static code analysis summation that was required, I'll try to find the time to try to explain why it now works ;)
PS: ADCON was a red herring in that it is used in an #ifdef...#else...#endif section for a build for a different 8051 variant of the common code (the C515C doesn't have an ADCON SFR). Short of putting the project options C51 tab define (cmd line -d) of "C515" into the C source, how does Lint know what external defines have been defined? I know, I'll go read the manual like I said I was going to do!
Much as with include paths, you need to define preprocessor symbols for lint as you do for your compiler.
Usually, I take care of this chore in the build tool (jam, make, whatever you like). Ideally your project build system lets you list the symbols and can wrap them in appropriate syntax for various tools like the compiler and lint.
Another strategy is to create an "project.h" which includes all the #defines that select options for the project, and have all header files include that first, so that the options can affect those headers. Then there's one common place to adjust the options that's not the command line of the various tools.
In general, I prefer to avoid conditional compilation in the first place; This is one of the reasons why.