From VC to G ++

Source: Internet
Author: User

For a recent project, we need to port the code from VC to G ++ for compilation. In this process, we encountered several platform-related problems-the Code Compiled smoothly under VC, however, an error is reported during compilation in G ++.

Here we will share it with you:

 

1. Enumeration type issue code
enum MyWeek{    Monday,    Tuesday,};MyWeek mw = MyWeek::Monday;
VC
D: \ Vc \ main. cpp (17): Warning c4482: non-standard extension used: the enumerated "myweek" is used in the qualified name"
G ++
main.cpp:11:14: error: ‘MyWeek’ is not a class or namespace  MyWeek mw = MyWeek::Monday;              ^
Summary

Myweek: Monday is not a C ++ standard, so avoid this method as much as possible. We recommend that you add a prefix of the enumeration type to the command enumeration to avoid repeated enumeration names. For example

enum MyWeek{    MW_Monday,    MW_Tuesday,};
2. STD: Map: cbegin () problem code
std::map<int, int>::const_iterator cIter = testMap.cbegin();
VC

Compiled successfully

G ++
main.cpp:7:53: error: ‘class std::map<int, int>’ has no member named ‘cbegin’  std::map<int, int>::const_iterator cIter = testMap.cbegin();                                                     ^
Summary

The result is run in G ++ 4.8.2, indicating that in G ++, there are no methods such as map: cbegin, MAP: Cend.

3. # include <map>

If there are spaces in the include header file, there is no problem in VC, but an error will be reported in G ++.

Main. cpp: 2: 16: Fatal error: Map: No file or directory # include <map> ^ compilation terminated.

From VC to G ++

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.