Compiler handles warnings, errors #pragma GCC diagnostic ignored "-wunused"

Source: Internet
Author: User

GCC warnings at all levels
Overwrite from top to bottom

Variable (code) level: Specify a variable warning

int a __attribute__ ((unused));
Specifies that the variable is unused. Even if the variable is not used, a warning output is ignored at compile time.


FILE-level: diagnostics (Ignore/warn) in source code files

Grammar:
#pragma GCC diagnostic [error|warning|ignored] "-w< warning Options >"
Diagnostics-Ignore: (Turn off warning)


#pragma GCC diagnostic ignored "-wunused"
#pragma GCC diagnostic ignored "-wunused-parameter"
Diagnostics-Warning: (Turn on warning)

#pragma GCC diagnostic warning "-wunused"
#pragma GCC diagnostic warning "-wunused-parameter"
Diagnostics-Error: (Turn on warning-upgrade to error)

#pragma GCC diagnostic error "-wunused"
#pragma GCC diagnostic error "-wunused-parameter"
Usage:
Close the warning at the beginning of the file, and then turn on the warning at the end of the file to ignore the specified warning in the file.


Project-level: command line/compile parameters specified

Warning:
GCC Main.c-wall ignored:
GCC Mian.c-wall-wno-unused-parameter//Open all warning, but ignore-unused-parameter warning

Option format:-w[no-]< warning Options >
such as:-wno-unused-parameter # no-indicates that this warning is ignored when diagnosing

Compiler handles warnings, errors #pragma GCC diagnostic ignored "-wunused"

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.