Go to: Cause of c4541 warning in vc6.0 and solution (dynamic_cast error)

Source: Internet
Author: User

Turn: http://hi.baidu.com/nkhzj/blog/item/0c4ade167010a81b972b4307.html


Today, when using the dynamic_cast <> operator in vc6.0, an unknown warning is reported:
Warning c4541: 'dynamic _ cast' used on Polymorphic type 'class myobject' with/GR-; unpredictable behavior may result.
This warning is actually a serious error.ProgramException aborted, I can check and findCodeNo error ?! Later, when msdn queries the meaning of the compiler/GR options, it finally figured out this problem.

It turns out that the vc6.0 compiler does not support rtti in C ++ by default, so a warning will be issued when compiling a program containing the dynamic_cast or typeid operator. The "/GR-" option means to disable "/GR" (that is, grant rtti ). To remove this warning, enable the "/GR" option or directly add "/GR" to the compiler parameters.


The full text in msdn is described as follows:

/GR (enable run-time type information)

The enable run-time type information Option (/GR) causes the compiler to add code to check object types at run time. When this option is specified, the compiler defines _CpprttiPreprocessor macro. The option is cleared (/GR-) by default.

To find this option in the development environment, clickSettingsOnProjectMenu. Then clickC/C ++Tab, and click C++ LanguageInCategoryBox.

Related Article

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.