I am in the process of writing a library and I am not getting the results that I am expecting when from some preprocessing commands.
Below is the block of preprocessor code in my header file, foo.h:
#if G_VAL < GS_90 #define G_CONVERSION 0 #define MODE 31 #else #define G_CONVERSION 50 #define MODE 39 #endif
Relevant PDE source:
//#define G_VAL GS_15 #define G_VAL GS_90 #include <MMA7361.h>
If I define G_VAL in foo.h, I have no issue. When I move the #define to a pde file, prior to the #inlcude<foo.h> line, I have problems. MODE which is only used in the pde file is properly set, but G_CONVERSION which is used in foo.cpp is not set correctly. They are always set to 1 and 0 respectively regardless of the value assigned to G_VAL. If I remove the #defines from the first part when G_VAL == GS_90, the compiler throws a couple of errors stating that G_CONVERSION is not in the scope. There is no error with MODE.
Are the preproccesor commands in the pde file processed after foo.cpp and foo.h are compiled regardless of the fact that the include is after those commands? Or, am is there something that I should/can fix?