#pragma comment

Category

Object code control

Purpose

Places a comment into the object module.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-#--pragma--comment------------------------------------------->

>--(--+-compiler-----------------------------------+--)--------><
      +-date---------------------------------------+      
      +-timestamp----------------------------------+      
      '-+-copyright-+--+-------------------------+-'      
        '-user------'  '-,--"--token_sequence--"-'        

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 we have the following program code: tt.c:
#pragma comment(date)
#pragma comment(compiler)
#pragma comment(timestamp)
#pragma comment(copyright,"My copyright")
int main() { return 0; }
Issuing the command:
xlc -c tt.c
strings -a tt.o
will cause the comment information embedded in tt.o to be displayed, along with any other strings that may be found in tt.o. For example, assuming the program code shown above:
@.text
.data
@.bss
.comment
Thu Sep 24 16:44:25 EDT 2014IBM XL C for AIX ---- Version 13.1.0.0
Thu Sep 24 16:44:09 EDT 2014
main
My copyright
.file
tt.c
.text
.data
.bss
.main
_$STATIC
_$STATIC
main
main
Thu Sep 24 16:44:25 2014
IBM XL C for AIX, Version 13.1.0.0 ---