为什么在 Visual Studio 中满足断点条件时却未满足我的断点条件?

发布于 2024-08-09 09:02:05 字数 879 浏览 7 评论 0原文

我面前有一段代码,它循环访问一长串 url,当这些 url 包含某种类型的文档时,就会出现问题。我不想看到每次迭代,所以我设置了一个条件断点。

问题是我不是一个 C++ 程序员,所以我不得不四处寻找如何做我想做的事情,而且我可能会做一些明显错误的事情。

我当前的条件是这样的:

(strstr( url, "xlsx") == 0x00000000)

这应该意味着每次 url (这是一个 UNICODE_char* )不包含文字“xlsx”时 strstr 将返回一个应该与条件匹配的空指针,据我所知。从长远来看,我实际上希望它反过来,但由于只有几个“xlsx”网址,而且我想检查它是否正常工作,所以我现在就这样了。

好吧,我的条件没有得到满足,或者至少断点没有被触发。

假设我做错了什么,我复制了与监视表达式相同的值,并在之前的行上设置了无条件断点。当我越过共同断点时,结果如下所示:

Name                                 | Value
================================================
(strstr( url, "xlsx") == 0x00000000) | true

显然,就监视窗口而言,我的条件可能为真,但不会触发条件断点。

为了进一步实验,我尝试翻转条件,因此

(strstr( url, "xlsx") != 0x00000000)

就条件断点而言,这也是错误的,这似乎有点有趣,因为这意味着它既不等于也不不等于空指针值。

这是 C++ 中空值的一些不寻常的属性吗?是否有一些明显的我遗漏的东西,或者语言的某些怪癖导致我完全错过了这艘船?

I have a piece of code in front of me that iterates through a long list of urls and something is going wrong when those urls include a certain type of document. I don't want to see every iteration, so I've set up a conditional breakpoint.

The trouble is that I'm not a C++ programmer so I'm slightly having to fish around to work out how to do what I want and I may be doing something obviously wrong.

My current condition is thus:

(strstr( url, "xlsx") == 0x00000000)

This should mean every time the url ( which is a UNICODE_char* ) doesn't contain the literal "xlsx" strstr will return a null pointer which should match the condition, as I understand it. I actually want it the other way round in the long term, but as there are only a couple of "xlsx" urls and I want to check it is working I have it this way up for now.

Well, my condition is not being met or at least the breakpoint is not being triggered.

Assuming that I was doing something wrong I copied the same value as a watch expression and set an unconditional breakpoint on the line before. The result looks like this as I step past my coinditional breakpoint:

Name                                 | Value
================================================
(strstr( url, "xlsx") == 0x00000000) | true

So apparently my condition can be true as far as the watch window is concerned but not trigger the conditional breakpoint.

In order to experiment further I tried flipping the condition over so it was

(strstr( url, "xlsx") != 0x00000000)

As far as the conditional breakpoint is concerned this is also false, which seems a bit funny as that would mean it neither equalled nor didn't equal the null pointer value.

Is this some unusual property of null values in C++? Is there something really obvious I'm missing or some quirk of the language that is causing me to totally miss the boat on this one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

·深蓝 2024-08-16 09:02:05

如果您的 url 是 unicode 字符串,您是否尝试过使用 wcssstr?

If your url is a unicode string, have you tried using wcsstr?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文