Linux GCC compilation error (reprint)

Source: Internet
Author: User

Transferred from: http://www.linuxidc.com/Linux/2012-01/52153.htm

C programming under Linux is different from Windows, if you are using GCC to compile code with the hint ' for ' loop initial declarations is only allowed in C99 mode, Maybe it's because you're using an undefined variable in the loop loop like for, like:

for (int i=0;i<10;i++)

{

}

This kind of writing in VC is not wrong, and sub-GCC will prompt error, requirements to comply with C89 standards, C89 standard is not supported by the above-mentioned notation. If you have to write like this, you can compile this, using the C99 standard:

GCC Helo.c-std=c99-o Hello

Of course, you can also define the I variable first.

int i;

for (i=0;i<10;i++)

{

}

This will not prompt the ' for ' loop initial declarations is only allowed in C99 mode such a mistake

Linux GCC compilation error (reprint)

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.