Struct _ Position {} and assert

Source: Internet
Author: User

What is the difference between assert and verify Macros:
1 assert and verify macros work basically the same in debug mode. Both of them calculate the expression value. If the value is not 0, nothing will be done. If the value is 0, the diagnostic information is output.
2 assert and verify macros have different effects in the release mode. Assert does not calculate the expression value or output diagnostic information. Verify calculates the expression value, but does not output diagnostic information no matter whether the value is 0 or not.
Verify and assert are essentially different in program debugging.

By the way, it is worth mentioning thatVerify () Macro, which allows you to put program code in a Boolean expression. This macro is usually used to check the return values of Windows APIs. Some people may abuse verify () For this reason. In fact, this is dangerous because verify () violates the idea of assertions and cannot completely separate program code from debugging code, in the end, it may cause a lot of trouble. Therefore, experts suggest using this macro as little as possible..

The basic header file afx. h of VCPositionIs defined as follows:
Struct _ Position {};
Typedef _ Position * position
Obviously, a struct without any fields is defined here, and position is the pointer of this struct.

When VC uses clist, some functions usually use the position parameter or return the position type. In fact, you can see the original code of clist. The position returned by clist is a node pointer of its linked list, that is to say, there is a cNode class in the clist that defines the node, and the position is the cNode *

Therefore, although the _ Position struct does not have any fields, the position struct pointer is only used to express the cNode * pointer and is forcibly converted. Therefore, position is used by VC as a common data type-32-bit pointer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.