Quote:
|
How have you been using the preprocessor to handle defines? It's more conventional (from the C++ standpoint) to use the "const" keyword.
|
i use enum { Var1, Var2}; and const float speed=1; but just at the top or near the top #define VAR_NAME 1(Optional value)
also
Quote:
#ifdef WPI_STATUS_DEFINE_STRINGS
#define S(label, offset, message) const int wpi_v_##label = offset; const char *wpi_s_##label = message ;
#else
#define S(label, offset, message) const int wpi_v_##label = offset; extern const char *wpi_s_##label;
#endif
|
a file may be included more than once (weird, i know, but that is the way the C++ compiler works) so the compiler sees:
Code:
if i have not defined "WPI_STATUS_DEFINE_STRINGS" then
{
replace the macro "S(label, offset, message)" with
{
const int wpi_v_##label = offset;
const char *wpi_s_##label = message ;
}
}
else (if i have defined "WPI_STATUS_DEFINE_STRINGS")
{
replace the macro "S(label, offset, message)" with
{
const int wpi_v_##label = offset;
extern const char *wpi_s_##label;
}
}
Got it? (I like medium level languages that are safer like C# or (ick!)VB!)