Thread: Editing Main.c
View Single Post
  #7   Spotlight this post!  
Unread 31-01-2004, 23:08
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Editing Main.c

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
of course it does. i comment the heck out of my code, as well as try to arrange it in the most logical way possible

I think what Random Dude meant was that you could use #includes so that you could be sure that the code you were writing would be executed for one mode or another, depending on what file you put it in. that way, you still have both autonomous mode and operator mode, but the code for each is in separate files.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)