Warning c4996: 'swprintf': swprintf has been changed to conform with the iso c standard,

Source: Internet
Author: User

This is a problem today: (I use vs2008)

Code:

swprintf( tempwcX, L"%s", tempStrX.c_str());

Error:

D: \ Visual Studio 2008 \ projects \ testregex. CPP (53): Warning c4996: 'swprintf': swprintf has been changed to conform with the iso c standard, adding an extra Character Count parameter. to use traditional Microsoft swprintf, SET _ crt_non_conforming_swprintfs.

1> D: \ Program Files \ Microsoft Visual Studio 9.0 \ Vc \ include \ swprintf. INL (85): see the "swprintf" statement.

I did not find the specific reason for various searches on the Internet, and then I returned to msdn. I saw the following sentence:

In Visual C ++ 2005, swprintf conforms to the iso c standard, which requires the second parameter, count, of Type
Size_t. To force the old nonstandard behavior, define_crt_non_conforming_swprintfs. In a future version, the old behavior may be removed, so code shocould be changed to use the new conformant behavior.

(IN Vc ++ 2005, swprintf follows the International Standards Organization standard C and requires the second size_t type count ........ In later versions, old behaviors will be removed, so the code should use new consistent behaviors. (If the translation is poor, let's take a look ...)

Therefore, you can ignore this error directly. If you see this warning uncomfortable, you can add a parameter count, for example:

swprintf( tempwcX, 100, L"%s", tempStrX.c_str());

Tested by myself, warning is gone.

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.