C + +: warning:deprecated conversion from string constant to ' char* ' [-wwrite-strings]

Source: Internet
Author: User
Tags deprecated

2016-12-5 16:17:09

----------------------------

In the development of the CTP system under CentOS, in the process of introducing C + + program, compile (g++ * * * *), there are the following tips

"1" testmdapi.cpp:15:45: warning:deprecated Conversion from string constant to ' char* ' [-wwrite-strings]
Char *ppinstrumentid[] = {"cu0907", "cu0909"}; Market Subscription List
^
TESTMDAPI.CPP:15:45: warning:deprecated Conversion from string constant to ' char* ' [-wwrite-strings]

Although there is such a hint, but it is still valid C + + code, because the written char* is a C-style string, so g++ does not recognize

You can choose to add when compiling: g++-wno-write-strings text.cpp//Ignore warning ...

Actually, it's not very safe.


"2" testmdapi.cpp:21:15: Error: ':: Main ' must return ' int '
void Main (void)

Not a problem with the code, but a compiler problem

The C language standard allows the main function to be void type

Instead, the standard for C + + must be of type int

However, many Ides or compilers do not necessarily keep the C + + standard, such as vs

C + +: warning:deprecated conversion from string constant to ' char* ' [-wwrite-strings]

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.