|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Critique this code
He's right in that in control_system.c your indenting is inconsistent. Quite a few more comments explaining why things are done and what functions actually do in plain English would be helpful.
I really don't like using multiple returns from a function. You're more likely to screw up your logic when you make changes with multiple returns and it's harder for outsiders to trace that logic. With the compiler warning level set high enough, and I really, really recommend you set it at the highest and fix your code so NO warnings are generated, functions like joystick_deadpan and percentage_limit will generate a warning because technically they are expected to return a value and when you just hit the closing curly brace you're returning void. Some of these things may seem nit picking but they're what make the difference between good code and four letter word code. And I've spent too much of my life trying to fix the latter kind.Last edited by TimCraig : 06-04-2006 at 00:48. Reason: typo |
|
#2
|
|||
|
|||
|
Re: Critique this code
Okay, does anyone know which of the arguments for the Microchip compiler turn the warnings way way up?
I develop under Linux with a makefile so I can edit the arguments freely. |
|
#3
|
|||
|
|||
|
Re: Critique this code
-w3 is the highest and gives "errors, warnings, and messages" -w1 is the lowest at errrors only. It looks like it defaults to -w2 because MPLAB doesn't show anything when I set that. That level is errors and warnings. I would use at least -w2 and then fix your code so there are no errors generated. If you don't, you and your successor will have to wade through a ton of warnings and may miss something important.
I'm not sure how stringent C18 is in generating warnings. If you get serious about it, you can run your code through a Lint program and generate a more comprehensive set of warnings. One place I used to work required we crank up the compiler and fix those warnings and then Lint it and fix those. Sometimes it was tough to make both happy but worth it. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Out of the Box Camera Code | russell | Programming | 9 | 21-10-2009 05:28 |
| Problem with idata_user_routines.o? | Adrien | Programming | 3 | 12-02-2006 01:33 |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |
| Sourceforge for Code Repository and other stuff | SilverStar | Programming | 9 | 15-01-2005 21:16 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |