??? 05/20/04 19:14 Read: times |
#70765 - RE: how to use to header files in one fi Responding to: ???'s previous message |
Absolutely true. But watch the original post:
#ifdef slow_chrg (...) on poweron slow_chrg bit is 1 and while in program working it will become 0 so that the other values is to be assigned. So it theoretically could be done, with extra safeguards as #ifdef slow_chrg # ifdef chnl1_vol # undef chnl1_vol # endif # define chnl1_vol 0x400 # ifdef chnl2_vol # undef chnl2_vol # endif # define chnl2_vol 0x400 and so on... etc etc, to handle changing the macros on compile time depending on slow_chrg (assuming you consider defined=1, undefined=0), though it would be rather cumbersome I think. Since the chnl... "variables" are in fact macros and changing them "on the fly" like that, so one part of the program contains one set and another the other (while the program is working...) implies reusing same pieces of code instead of writing functions for them, which might in certain conditions speed things up a little bit but leads to awful code bloat. "while the program is working it will become zero" I could imagine as something like this: /* startup */ #define slow_chrg #include<shift_volumes.h> med=(a*chnl1_vol+b*chnl2_vol+c*chnl3_vol)/3; /* (...) */ /* late program */ #undef slow_chrg #include<shift_volumes.h> med=(a*chnl1_vol+b*chnl2_vol+c*chnl3_vol)/3; -I- don't like this code. |