Quote:
|
Originally Posted by mtrawls
What? #include statements are pre-processor directives ... they are (quite necessarily) executed before compilation and definately before you upload the code to the robot. For conditional includes, you'd have to use the pre-processor directive #ifdef ... #endif -- but this isn't what you mean to do. Presumably, everytime you run the robot you'd want to execute *both* autonomous mode, and manual mode -- meaning you'd more than likely want both "auton.c" and "manual.c" to be included every time. Instead of #include "auton.c", perhaps you mean some sort of function call, where the function is defined in auton.c? *color me confused*
That's not such a big concern, though. If something increases readability, or efficiency, or some other desirable thing, you very may well say "re-usability be damned." Reducing code duplication is good because it reduces your work, and reduces the amount of errors creeping up because of subtly different versions ... but it isn't necessarily bad (not that it is--or isn't-- justified here). Oh, and all I really wanted was an excuse to say this (sorry that I forget who it was that said it): For code to be re-usable, it first has to be usable 
|
No, that *should* work as is.... since the preprocessor would stick both of the files in and then everything would compile. That being said, I do agree that making then relevant sections into functions (in seperate files if you insist), would make much more sense.