#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|
|B||Problem with 433MHz (With HT12E/D included ) while using HIGH RPM Motor||Wireless & RF Design||6|
|Question About Volume Control Problem While Playing Videos||Off-Topic||1|
|Problem while implementing a circuit.||General Electronics Chat||9|
|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|
|Problem with 433MHz (With HT12E/D included ) while using HIGH RPM Motor|
|Question About Volume Control Problem While Playing Videos|
|Problem while implementing a circuit.|
|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 Luke James
by Jake Hertz
by Luke James