Chapter 13. Warning Suppression Control #pragma Directives
Prev |  | Next

## Chapter 13. Warning Suppression Control `#pragma` Directives

Table 13-1 lists the `#pragma` directives discussed in this chapter, along with a brief description and the compiler versions in which the directive is supported.

Table 13-1. Warning Suppression Control `#pragma` Directives

#pragma | Short Description | Compiler Versions
--- | --- | ---
`#pragma set woff` | Suppresses compiler warnings (either all, or by warning number). | 7.2 and later
`#pragma reset woff` | Resets listed warnings to the state specified in the command line. | 7.2 and later

## `#pragma set woff`

The `#pragma set woff` directive suppresses compiler warnings individually by warning number.

The syntax of `#pragma set woff` is as follows:

    #pragma set woff [warning_list]

warning_list is a list of the warning numbers that you want suppressed. Ranges are allowed. Only the specified compiler warnings are suppressed.

For example, the following directive turns off warnings 1, 2, 300 through 310, and 8:

    #pragma set woff 1,2,300-310,8

`#pragma set woff` does not nest. That is, any `#pragma reset woff` on a given number resets the value to that implied by the command line.

Example 13-1. `#pragma set woff`

The following code illustrates the use of `#pragma set woff` :

    cc -woff 300,302

    /*  example.c */
    #pragma set woff 400
    /* warnings 300,302, and 400  are off  in example.c */

    #include “example.h”
    /* You would expect that warnings 300,302,and 400 would be off
    in example.h. However, the #pragma set woff does not travel
    into #includes properly. In MIPSpro7.2 300 and 302 are off, but
    400 is on in example.h. In a future release 400 may be off in
    example.h
    */

    #pragma reset woff 400
    /*  400 is reset to command line state; that is, 400 is on. */

    #pragma reset woff 300
    /* 300 is reset to command line state; that is, 300 is still off */

## `#pragma reset woff`

The `#pragma reset woff` directive resets listed warnings to the state specified in the command line.

The syntax of `#pragma reset woff` is as follows:

    #pragma reset woff [warning_list]

warning_list consists of a list of the warning numbers that you want reset to the state specified in the command line. Ranges are allowed. Only the specified compiler warnings are reset.

For example, the following directive sets warnings 1, 2, 300 through 310, and 8 back to the command-line setting:

    #pragma set woff 1,2,300-310,8

This directive does not nest.

Example 13-2. `#pragma reset woff`

The following code illustrates the use of `#pragma reset woff` :

    cc -woff 300,302

    /*  example.c */
    #pragma set woff 400
    /* warnings 300,302, and 400 are off in example.c */

    #include “example.h”
    /* You would expect that warnings 300,302,and 400 would be off
    in example.h. However, the #pragma set woff does not travel
    into #includes properly. In MIPSpro7.2 300 and 302 are off,
    but 400 is on in example.h. In a future release 400 may be off
    in example.h
    */

    #pragma reset woff 400
    /*  400 is reset to command line state; that is, 400 is on. */

    #pragma reset woff 300
    /* 300 is reset to command line state; that is, 300 is still off */

Prev | Table of Contents | Next
Chapter 12. Scalar Optimization #pragma Directives |  | Chapter 14. Miscellaneous #pragma Directives