In the following sample (.cpp file), the symbols STR_1 and STR_2 are not recognized correctly (IntelliSense, coloring, ...).
#ifdef RC_INVOKED
#define DECLARE_TEXT(NUM, STR, TEXT) NUM TEXT
STRINGTABLE FIXED PURE
BEGIN
#else
#define DECLARE_TEXT(NUM, STR, TEXT) STR = NUM,
enum StringIds {
#endif
DECLARE_TEXT(1, STR_1, "My string 1")
DECLARE_TEXT(2, STR_2, "My string 2")
#ifdef RC_INVOKED
END
#else
};
#endif
#undef DECLARE_TEXT
int main()
{
return STR_1;
}
Things change if the logic of the first preprocessor construct is reversed:
#ifndef RC_INVOKED
#define DECLARE_TEXT(NUM, STR, TEXT) STR = NUM,
enum StringIds {
#else
#define DECLARE_TEXT(NUM, STR, TEXT) NUM TEXT
STRINGTABLE FIXED PURE
BEGIN
#endif
DECLARE_TEXT(1, STR_1, "My string 1")
DECLARE_TEXT(2, STR_2, "My string 2")
#ifndef RC_INVOKED
};
#else
END
#endif
#undef DECLARE_TEXT
int main()
{
return STR_1;
}
Obviously, VAX blindly enters the #if alternative, without recognizing that RC_INVOKED most probably isn't defined in C++ files. Is this by design, or just a missing feature?