#pragma message

From RAD Studio
Jump to: navigation, search

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.
  • The classic compiler prints each string within double quotes.
  • The clang-based compiler does not use any quotes.

Example:

#pragma message "Compiling " FILE " now..."
Allowed.png
Allowed.png
2 #pragma message [string|number]+ No parentheses A #pragma message followed by strings or numbers.

Example:

#pragma message "Compiling " FILE " now..." __CODEGEARC__ 
Allowed.png
3 #pragma message(string+) With parentheses A #pragma message followed by one or more strings.
  • The classic and the clang-based compilers concatenate the strings into one message without quoting.

Example:

#pragma message( "Compiling " FILE " now...") 
Allowed.png
Allowed.png
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.

See Also