How do I enable GCC to handle double slash annotations (c + + style annotations)?

Source: Internet
Author: User

Recently, when dealing with a third party code, it was found that the GCC compiler could not handle double slash annotations correctly (//). After consulting some information, it was found that GCC uses a different C standard to determine whether it can handle double slash annotations correctly.

Because the-ansi switch is added to the cflags in the makefile, and-ansi is equivalent to-std=c89, follow the C89 specification and not be able to handle double slash annotations. Some articles mention adding-wp,-lang-c-c++-comments to GCC to solve this problem, but in practice this option is obsolete after GCC 2.x. The appropriate solution, therefore, is to change-ansi to-std=gnu89 (note not c89), gnu89 the equivalent of c89 plus some GCC extensions, including double slash annotation forms. In addition, note that although written as-std=c99 can also handle double slash annotation, but because the C99 standard incorporates some C + + specification, and ANSI difference is larger, therefore not recommended.

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.