[NXC] How important is the order of Voids?
Posted: 25 Sep 2011, 10:34
I'm modifying a complex NXC program and all is going well.
I'm now at the stage of insterting a few last subroutines (voids) and I ran into a couple of problems, one I've solved.
1st of all, there is a core Void routine that does all the work. I'd built all the mechanical subroutines (voids) below it, and tested them all manually )I tested them by calling them from "main" void which is right at the bottom. All was fine.
Then I moved the calls to these routines to the main code which is much further up.
When I inserted the calls to the "below" voids, the compiler (Brixcc) started moaning about unidentified references. i.e. in my primary void (not main btw) I called xxxxx(); which was physically below in the code. Easy to solve, I moved the subroutine voids above the primary routine and all works fine. I was a little surprised as I though the program jumped from void to void as commanded and picked up variables as it went.
The compiler was complaining about missing void names, not variables.
Now, I'm modifying some of the void subroutines that i've moved up to the top, referencing variables that are created much further down in lower voids, and of course have run into the same problem (even though, in the correct running order of the program (logically) the variables are set in earlier code. I can't move the voids back down lower as I just moved them up to solve problem numer one.
Do I need to define all of these variables in advance at the very top of the program with #defines? even if their contents will be purely ficticious at the beginning.
I'd show the code but it's far too long
I'm now at the stage of insterting a few last subroutines (voids) and I ran into a couple of problems, one I've solved.
1st of all, there is a core Void routine that does all the work. I'd built all the mechanical subroutines (voids) below it, and tested them all manually )I tested them by calling them from "main" void which is right at the bottom. All was fine.
Then I moved the calls to these routines to the main code which is much further up.
When I inserted the calls to the "below" voids, the compiler (Brixcc) started moaning about unidentified references. i.e. in my primary void (not main btw) I called xxxxx(); which was physically below in the code. Easy to solve, I moved the subroutine voids above the primary routine and all works fine. I was a little surprised as I though the program jumped from void to void as commanded and picked up variables as it went.
The compiler was complaining about missing void names, not variables.
Now, I'm modifying some of the void subroutines that i've moved up to the top, referencing variables that are created much further down in lower voids, and of course have run into the same problem (even though, in the correct running order of the program (logically) the variables are set in earlier code. I can't move the voids back down lower as I just moved them up to solve problem numer one.
Do I need to define all of these variables in advance at the very top of the program with #defines? even if their contents will be purely ficticious at the beginning.
I'd show the code but it's far too long