VC debugging technology tips (5)

zhaozj2021-02-16  55

At the same time, VC6 also provides a gadget for Error Lookup, which can convert the corresponding error code into a text description. See below:

And Windows itself provides functions such as formatmessage, which can convert the error code into text description, feedback to the user, which is not described herein.

Custom function error

Similarly, you can also display the error code to other calorificers. This can be achieved in two ways,

First, you can use the 32-bit error code already existing in the WineError.h header to implement it through the setLastError function. Second, if the 32-bit error code already existing in the WineError.h header file can not represent your error message, then you can customize your 32-bit error return code. When defining the error code, you must understand the error code domain, as shown below:

Error code domain

It should be noted that the user-defined error code must set 29 bits in the error code domain to 1. The implementation method is to add an error code macro definition, and then set it as the first case.

Release version debugging

In many programmers, only Debug is only debugged. In fact, for Release version of debugging is the same, some people may say that debugging under the debug version is enough, can run well under Debug version. In the Release version, there is no problem. In fact, this view is wrong. I have encountered many times during the process of writing the program, and a program can run well under Debug, but in Release, it is wrong. The reason is that the reason is the buffer off-road. If you can debug it under the release version, you can find a problem very quickly. In fact, the Release version debugging is very simple, as long as the setting of the VC compilation option can be achieved. The specific implementation method is as follows:

1. Open the VC Integrated Environment -> Project -> Setting dialog.

2. Select All Configuration options in the SERTTINGS for Combination box.

3, select C / C Tab, select the Program Database option in the Debug Info Combination box.

4. Switch to link Tab, select the debug option in the Category group box, then select the following debug info check box and the Microsoft Format flag.

After the setting is complete, you can debug

Debug

Debugging your version

RELEASE

The version is, but it is important to pay attention to

RELEASE

In the version, the compiler is optimized, some of the programs in the program code may not be executed

转载请注明原文地址:https://www.9cbs.com/read-22010.html

New Post(0)