views:

120

answers:

3
#pragma comment(lib, "kernel32")
#pragma comment(lib, "user32")
A: 

These link in the libraries selected in MSVC++.

bobobobo
+1  A: 

I've always called them "compiler directives." They direct the compiler to do things, branching, including libs like shown above, disabling specific errors etc., during the compilation phase.

Compiler companies usually create their own extensions to facilitate their features. For example, (I believe) Microsoft started the "#pragma once" deal and it was only in MS products, now I'm not so sure.

Pragma Directives It includes "#pragma comment" in the table you'll see.

HTH

I suspect GCC, for example, has their own set of #pragma's.

JustBoo
You misunderstood the question. He's not asking what pragmas are, and referring to them as comments instead of directives. He's asking specifically what `#pragma comment` means.
Rob Kennedy
Awkward here, it's actually a directive for the linker.
Hans Passant
@Hans: Hmm, so in this case we'd call it a "linker directive"?
JustBoo
+3  A: 

#pragma comment is a compiler directive which indicates Visual C++ to leave a comment in the generated object file. The comment can then be read by the linker when it processes object files.

#pragma comment(lib, libname) tells the linker to add the 'libname' library to the list of library dependencies, as if you had added it in the project properties at Linker->Input->Additional dependencies

See #pragma comment on MSDN

Samuel_xL