The problem is , i cant get the definitions to work globally if i do it in C and i can't use #if(PORTBbits.RB1 == 1) in preprocessor because, well it is preprocessor and therefore has no idea of the port state yet, and C30 compiler won't let you put a "." in an #if statement. Any Ideas?
You can not read a switch at run time then go back in time to recompile the code to use that definition.
You either need two code branches or
you can use a single function with calls to functions that check the switch (or a var set from it) and
act accordingly.
Code:
int sVal;
main()
{
sVal = PORTBbits.RB1;
... lots of code...
doThing1()
...more code...
}
// do the conditional part here
void doThing1()
{
if (sVal)
....
else
.... ;
}
OK, i have this so far (which works). Now i want to be able to use the same definitions in my other .c files without having to copy and paste this code into each of them. Any ideas?