English 中文(简体)
视觉C++ “失败”
原标题:Visual C++ "Debug Assertion Failed"

我用《2010年视觉演播室》汇编了一部法规,但不幸的是,在测试期间,我有时有错误:Debug Assertion Fail.Expression(unsingated)(c+1)<=256

然后,我尝试了同样的情况,但使用电梯,没有任何问题。 对这一问题有何想法?

问题回答

您再次称职,如字母字母()或数字(),其数值不是单列0-255。

一部法典说,“此时此刻,我们期望以下表述:<条码>(未签署)(c+1)”和“;=256条

The method to break into the debugger is platform dependent and probably not implemented correctly for gcc. I d look for this piece of code in the project and then try to find out why c is supposed to be less or equal to 255, and what makes it go out of range; letting the program run to the point where the assertion is triggered gives you an implicit breakpoint on the error condition, start with that.

I found that the problem cause is that how each compiler declare character. In Visual Studio, the default is Signed char. So each character is signed unless you explicitly precede its declaration with unsigned word. So in VS the range of the character is -128 to 127, and if the read char has an ASCII greater than 128, it will have a negative code in VS. And since this case is not handled in the functions isalpha, isdigit, etc. the function will failed. In gcc, the used methodology to set char to sign or unsigned is something like dynamic pre-processor.

在<代码><ctype.h>功能的意外投入方面,你成为不明确行为的受害者。 http://port70.net/~nsz/c11/n1570.html#7.4p1“rel=“nofollow”)第7.4节,C11标准第1段:

在所有情况下,该论点都是<条码>int,其价值应作为<条码>表示,<>unsign char/code>,或应等于或等于宏观<条码>。 如果该论点具有任何其他价值,则行为不明确。

换言之,如果x isn t in the range of [0.UCHAR_ Fair]/code> or EOF,你不得将其通过到<ctype.h> function。 推翻这一说法,是让你知道你违反了这一规则的相当令人信服的方法;大多数事情只会发生(例如,我可以想象出心脏的 b。)





相关问题
how to reliable capture display setting changed

static void Main() { // Set the SystemEvents class to receive event notification when a user // when display settings change. SystemEvents.DisplaySettingsChanged += new ...

Why use CComBSTR instead of just passing a WCHAR*?

I m new to COM. What exactly is the advantage of replacing: L"String" with CComBSTR(L"String") I can see a changelist in the COM part of my .NET application where all strings are replaced in this ...

COM Basic links

folks can you provide me the tutorial link or .pdf for learning basic COM?. i do google it.. still i recommend answers of stackoverflow so please pass me.. Thanks

Statically linking Winsock?

I m using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I m looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I ...