Description
The #pragma report directive controls the generation of specific messages. The pragma will take precedence over #pragma info. #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
There are three ways in which this directive can be
used:
#pragma report ( level, (E|W|I) ) #pragma report ( (enable | disable), message_number ) #pragma report (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.
|
||||||
| 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 #pragma info(all) 2 #pragma report(level, W)
In the example above, #pragma info declares all messages to be information messages. The pragma report instructs the compiler to to display only those messages with a severity of 'W' or warning messages. In this case, none of the messages will be displayed.
1 #pragma report(enable, CPPC1000) // enables message number CPPC1000 2 #pragma report(level, E) // display only error messages.
In the example above, if CPPC1000 was an error message, it would be displayed. If it was any other type of diagnostic message, it would not be displayed. 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.
1 #pragma report(level, I) 2 #pragma report(enable, CPPC1000) 3 #pragma report(level, E) 4 #pragma report(pop)
In line 1 of the example above, the initial report level is set to 'I', causing message CPPC1000 to display regardless of the type of diagnostic message it classified as. In line 3, a new report level of 'E' is set, indicating at 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'.
![]()
Preprocessor Directives - An
Overview
Preprocessor Directive -
#pragma
![]()
#pragma info
report level
Miscellaneous Option - report(level, ...)
