Hi, I am currently trying to get my code support two different type of LCD display, the only difference is the hardware level driver, so condional compilation directive has to be introduced. #ifdef DISPLAY_1 void display_driver() { // do one thing } #else void display_driver() { // do another thing } #endif However I don't want change the directive in the code, I would like to do it in the IDE, I guess it should be under project\option\C51, any one know how to do it ? Thanks in advance. Daniel
to reduce the amount of repeated typing, you could consider:
void display_driver() { #ifdef DISPLAY_1 // do one thing #else // do another thing #endif }
An alternative to conditional compilation would be to have two separate source files, each of which defines one version of display_driver(). You then use the 'Include in Build' file option to choose which one actually gets compiled... You could create two Targets for your project to manage this (you could also control the conditional-compilation with multiple Project Targets).
to reduce the amount of repeated typing, you could consider: even easier re typing in main .h file
#define DISPLAY_1 // comment out if not display 1
"even easier re typing" No - you miss the point. I was talking about the amount of typing in the two definitions of his driver - not the amount of typing to set the #define !!
Oh, well. I usually "get excited" when reducing typing is mentioned. It gives you more time to type comments. Erik