C Language and Libraries Help (clang.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
comment
◄Up► ◄Contents► ◄Index► ◄Back►
─────C/C++ Language─────────────────────────────────────────────────────────
Pragma: comment
Syntax: #pragma comment( comment-type [, commentstring])
Summary: The comment pragma allows you to place a comment record in
an object file or executable file.
The <comment-type> specifies the type of comment record. The
optional <commentstring> is a string literal that provides
additional information for some comment types. Because
<comment-type> is a string literal, it obeys all the rules for
string literals with respect to escape characters, embedded
quotation marks ("), and concatenation.
The following comment records are allowed:
Record Description
compiler Places the name and version number of the compiler in
the object file. This comment record is ignored by the
linker. If you supply a <commentstring> parameter for
this record type, the compiler generates a warning
error message.
exestr Places <commentstring> in the object file. At link
time, this string is placed in the executable file.
The string is not loaded into memory when the
executable file is loaded; however, it can be found
with a program that finds printable strings in files.
One use for this comment-record type is to embed a
version number or similar information in an
executable file.
lib Places a library-search record in the object file.
This comment type must be accompanied by a
<commentstring> parameter containing the name (and
possibly the path) of the library for which you want
the linker to search. Since the library name precedes
the default library-search records in the object file,
the linker searches for this library just as if you had
named it on the command line. You can place multiple
library-search records in the same source file; each
record appears in the object file in the same order in
which it is encountered in the source file.
user Places a general comment in the object file. The
<commentstring> parameter contains the text of the
comment. This comment record is ignored by the linker.
The following pragma causes the linker to search for the
EMAPI.LIB library. The linker searches first in the current
working directory and then in the path specified in the LIB
environment variable.
#pragma comment( lib, "emapi" )
The following pragma causes the compiler to place the name and
version number of the compiler in the object file:
#pragma comment( compiler )
NOTE: For comments that take a <commentstring> parameter, you can
use a macro in any place where you would use a string
literal, provided that the macro expands to a string
literal. You can also concatenate any combination of string
literals and macros that expand to string literals. For
example, the following statement is acceptable:
#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )
-♦-