#pragma report

C++ only

Description

The #pragma report directive controls the generation of specific messages. The pragma will take precedence over #pragma info. Specifying #pragma report(pop) will revert the report level to the previous level. If no previous report level was specified, then a warning will be issued and the report level will remain unchanged.

Syntax

Read syntax diagramSkip visual syntax diagram>>-#--pragma--report--(--+-level--,--+-E-+----------------+--)-><
                         |           +-W-+                |
                         |           '-I-'                |
                         +-+-enable--+--,--message_number-+
                         | '-disable-'                    |
                         '-pop----------------------------'

where:

level Indicates the minimum severity level of diagnostic messages to display.
E | W | I Used in conjunction with level to determine the type of diagnostic messages to display.
E
Signifies a minimum message severity of 'error'. This is considered as the most severe type of diagnostic message. A report level of 'E' will display only 'error' messages. An alternative way of setting the report level to 'E' is by specifying the -qflag=e:e compiler option.
W
Signifies a minimum message severity of 'warning'. A report level of 'W' will filter out all informational messages, and display only those messages classified as warning or error messages. An alternative way of setting the report level to 'W' is by specifying the -qflag=w:w compiler option.
I
Signifies a minimum message severity of 'information'. Information messages are considered as the least severe type of diagnostic message. A level of 'I' would display messages of all types. The compiler sets this as the default option. An alternative way of setting the report level to 'I' is by specifying the -qflag=i:i compiler option.
enable | disable Enables or disables the specified message number.
message_number Is an identifier containing the message number prefix, followed by the message number. An example of a message number is: CPPC1004
pop resets the report level back to the previous report level. If a pop operation is performed on an empty stack, the report level will remain unchanged and no message will be generated.

Examples

  1. Specifying #pragma info instructs the compiler to print all informational diagnostics. The pragma report instructs the compiler to display only those messages with a severity of 'W' or warning messages. In this case, none of the informational diagnostics will be displayed.
    1  #pragma info(all)
    2  #pragma report(level, W)
  2. If CPPC1000 was an error message, it would be displayed. If it was any other type of diagnostic message, it would not be displayed.
    1  #pragma report(enable, CPPC1000)  // enables message number CPPC1000
    2  #pragma report(level, E)	  // display only error messages. 
    Changing the order of the code like so:
    1  #pragma report(level, E)
    2  #pragma report(enable, CPPC1000)
    would yield the same result. The order in which the two lines of code appear in, does not affect the outcome. However, if the message was 'disabled', then regardless of what report level is set and order the lines of code appear in, the diagnostic message will not be displayed.
  3. In line 1 of the example below, the initial report level is set to 'I', causing message CPPC1000 to display regardless of the type of diagnostic message it is classified as. In line 3, a new report level of 'E' is set, indicating only messages with a severity level of 'E' will be displayed. Immediately following line 3, the current level 'E' is 'popped' and reset back to 'I'.
    1  #pragma report(level, I)
    2  #pragma report(enable, CPPC1000)
    3  #pragma report(level, E)
    4  #pragma report(pop)

Related information