#pragma comment
Applicable invocations
| Pragma | xlc (Compiling C) | xlC (Compiling C++) | xlclang (Compiling C) | xlclang++ (Compiling C++) |
|---|---|---|---|---|
#pragma comment |
✓ | ✓ |
Note: Only typical invocations are listed in this table. You can refer
to the full list of compiler
invocations for all basic
invocations and their equivalent special invocations.
Category
Purpose
Places a comment into the object module.
Syntax
Parameters
- compiler
- Appends the name and version of the compiler at the end of the generated object module.
- date
- The date and time of the compilation are appended at the end of the generated object module.
- timestamp
- Appends the date and time of the last modification of the source at the end of the generated object module.
- copyright
- Places the text specified by the token_sequence, if any, into the generated object module. The token_sequence is included in the generated executable and loaded into memory when the program is run.
- user
- Places the text specified by the token_sequence, if any, into the generated object module. The token_sequence is included in the generated executable but is not loaded into memory when the program is run.
- token_sequence
- The characters in this field, if specified, must be enclosed in double quotation marks ("). If the string literal specified in the token_sequence exceeds 32 767 bytes, an information message is emitted and the pragma is ignored.
Usage
More than one comment directive can appear in a translation unit, and each type of comment directive can appear more than once, with the exception of copyright, which can appear only once.
You can display the object-file comments by using the operating system strings command.
Examples
Assume that the code of
tt.c is as follows:
#pragma comment(date)
#pragma comment(compiler)
#pragma comment(timestamp)
#pragma comment(copyright,"My copyright")
int main() { return 0; }
To display the comment information embedded in
tt.o, along with any other
strings that can be found in the code, issue the command:
xlc -c tt.c
strings -a tt.oThe preceding code might produce the following results:
@.text
.data
@.bss
.comment
Thu Dec 24 16:44:25 EDT 2018IBM XL C for AIX ---- Version 16.1.0.0
Thu Dec 24 16:44:09 EDT 2018
main
My copyright
.file
tt.c
.text
.data
.bss
.main
_$STATIC
_$STATIC
main
main
Thu Dec 24 16:44:25 2018
IBM XL C for AIX, Version 16.1.0.0 ---
