#pragma message
Go Up to Pragma Directives Overview Index
Syntax (See Pseudo-grammar)
#pragma message ("text" ["text"["text" ...]]) #pragma message text
Description
Use #pragma message
to specify a user-defined message within your program code.
There are different ways to use the directive, and its usage varies depending on the compiler being used.
Option | #pragma Sample | Style | Notes | Classic | Clang-based |
---|---|---|---|---|---|
1 | #pragma message strings+
|
No parentheses | A #pragma message followed by one or more strings.
Example: #pragma message "Compiling " FILE " now..." |
![]() |
![]() |
2 | #pragma message [string|number]+
|
No parentheses | A #pragma message followed by strings or numbers.
Example: #pragma message "Compiling " FILE " now..." __CODEGEARC__ |
![]() |
|
3 | #pragma message(string+)
|
With parentheses | A #pragma message followed by one or more strings.
Example: #pragma message( "Compiling " FILE " now...") |
![]() |
![]() |
Note: The clang-based compiler generates the message as a warning. Disable the message by turning off the relevant warning using the
#pragma-messages
.User-defined messages are displayed as messages, not warnings.
Display of user-defined messages is on by default and can be turned on or off with the Show Messages option. This option corresponds to the compiler's -wmsg switch.
Messages are only displayed in the IDE if Show general messages is checked on the C++ Project Properties under Project > Options > Project Properties.