#define and #if do not generate executable code as your logic seems to indicate.
#define is used to create text substitution macros that are performed BEFORE the compiler makes its first pass over the source code.
#if, #else, and #endif are used to perform conditional compilation. That is under some conditions you include or don't include a chunk of source code. This all happens BEFORE compilation of the source code begins.
#define Volt 2 #if Volt==2 //works #define MULTI 25 #elif Volt==2.5 // not work #define MULTI 20 #endif
#define v V2_5 #if v == V2_0 #define MULTI 25 #elif v == V2_5 #define MULTI 20 #endif
While using #define i got problem.
Compiler is not accepting floating values.
my scenario is as follows.
#if volt==2.5 //not working but
#if volt==2 //works,
It likes numbers just fine, as long as they fit the constraints. The expression in a #if must be an integer expression.It looks like the preproccessor does not like numbers.
|Thread starter||Similar threads||Forum||Replies||Date|
|L||Python break out of while loop problem||Programming & Languages||2|
|R||I faced the problem while i make a digital clock.||Homework Help||4|
|B||Problem with 433MHz (With HT12E/D included ) while using HIGH RPM Motor||Wireless & RF Design||6|
|J||Insulation Crimp problem while crimping Molex's Crimp shells using Pro's Kit 608384 tool||General Electronics Chat||5|
|S||Problem in PIC Kit 2 while using it for 16F84A||Microcontrollers||14|
|Python break out of while loop problem|
|I faced the problem while i make a digital clock.|
|Problem with 433MHz (With HT12E/D included ) while using HIGH RPM Motor|
|Insulation Crimp problem while crimping Molex's Crimp shells using Pro's Kit 608384 tool|
|Problem in PIC Kit 2 while using it for 16F84A|
by Jake Hertz
by Jake Hertz
by Jeff Child