Reputation: 20058
So I have this simple code snippet:
CString str;
..................
if ( str.IsEmpty() )
str = spRelease->GetID();
I want to put a conditional breakpoint on the last line to test if str is empty. I tried this first:
str == ""
But I get this:
Error overloaded operator not found
Then this:
str.isEmpty() == 0
And get this:
Symbol isEMpty() not found
Any idee how this could be done ? Any workaround ?
Thanks.
Upvotes: 1
Views: 2965
Reputation: 6821
One pattern that I've seen for things like this is to add a bit of code like this:
if (some_condition) {
int breakpoint=rand();
}
This generates a warning about breakpoint
being initialized but not used so it is easy to remember to take it back out. This also allows you test any condition you want, including invoking functions or anything else, without having to worry about restructions of the debugger. This also avoids the limit on the number of conditional breakpoints you can have that some debuggers have.
The obvious downsides are that you can't add one during a debug session, recompiling, remembering to take them out, etc.
Upvotes: 0
Reputation: 9414
Why don't you just put a normal breakpoint on the last line? You already know str is empty. If you want to double check whether your string is empty, I would use an ASSERT instead.
If you really have to check your string, you have to check m_pszData
in your CString, so your condition looks like this:
str.m_pszData[0] == '\0'
Upvotes: 5
Reputation: 860
In Visual Studio 6 you have the operation IsEmpty(), note that the first 'I' is uppercase. You also have the Compare() operation. Which version of VS are you using?
Upvotes: 1