View previous topic :: View next topic |
Author |
Message |
cfernandez
Joined: 18 Oct 2003 Posts: 145
|
static c source code analysis |
Posted: Fri Aug 24, 2012 3:00 pm |
|
|
Any know a tool for static c code analysis that work with CCS?
Best Regards, |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
cfernandez
Joined: 18 Oct 2003 Posts: 145
|
|
Posted: Fri Aug 24, 2012 4:20 pm |
|
|
Dear PCM
thanks but I want a tool for control and check my code, for example:
Code: | void x( int a )
{
*a=4;
}
main( )
{
int b;
x( &b );
} |
Is this example the compiler not detect error.
I want a tool for check this stupid error.....
Best Regards, |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 24, 2012 5:07 pm |
|
|
You need a Lint program. About 12 years ago I made LClint work with
CCS, but I only used it for one project and I haven't used or tested it
since that time. So, I don't really have an recommendations for a lint program. |
|
|
cfernandez
Joined: 18 Oct 2003 Posts: 145
|
|
Posted: Fri Aug 24, 2012 6:03 pm |
|
|
I search in the web, if I found any I tell you...
Thanks!!!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sat Aug 25, 2012 3:48 am |
|
|
Problem is, that though possibly 'silly', it _is_ legal in C.
Remember C is basically an 'untyped' language with automatic casting between types. You can use a pointer as an integer, and an integer as a pointer. In fact if the variable was an int16, it'd work!. The only reason it won't, is that it throws away the top byte of the variable when it is passed...
Do your search for 'PCLint', which is a tool for picking up loose bits of 'fluff' in C. There is a stricter version 'plint', which will point out things that _might_ be bugs, like the one you post. However quite a bit of configuration will be needed, to code with the CCS peculiarities, like the size of the integer, and the restrictions on pointers to functions.
Best Wishes |
|
|
|