-
February 21st, 2022, 04:34 AM
#1
# character (in string generation ?)
I found this code in a header file here... it starts with a declaration of various 'DebugBit' types, followed by the declaration for a function which prints out some debug text:-
Code:
namespace DEBUG {
extern DebugBits State;
extern DebugBits Properties;
extern DebugBits Name;
extern DebugBits Locale;
// and various others...
}
void debug_print (const char* prefix, std::string str);
These get followed by a preprocessor directive for using the above:-
Code:
#define DEBUG_TRACE(bits, str) { debug_print (# bits, str); }
And later in the code, it tends to get used something like this:-
Code:
DEBUG_TRACE (DEBUG::State, "whatever");
I think that the intention of # bits is maybe to convert parameter 1 from an enumeration into the equivalent string - so DEBUG::State would get converted to the string "Debug::State". This apparently works for other compilers but MSVC gives me C2014 "preprocessor command must start as first nonwhite space"
Does this not work in MSVC or am I misunderstanding something
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
February 21st, 2022, 05:11 AM
#2
Re: # character (in string generation ?)
Hi John,
did you try to remove the space between # and bits ?
Victor Nijegorodov
-
February 21st, 2022, 07:54 AM
#3
Re: # character (in string generation ?)
Thanks Victor. I tried #bits and it worked. So I then returned to # bits and that now works too!! There must've been some weird character lurking there that wasn't visible.
"A problem well stated is a problem half solved.” - Charles F. Kettering
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|