What is #pragma comment?

Recently I got C++ source code from my friend regarding something I don’t know (yet). In that source there are #pragma comment macro which I didn’t familiar. So what is it?

According to Visual C++ documentation, #pragma comment is used to place a comment record into an object file or executable file. I think it means putting additional (user specified) information for linker. There are some specified type of this comment : compiler, exestr, lib, linker, user.

Source I received uses lib type to specify libs to link against. Actually I don’t really understand why someone specify it from source code, normally I will specify what libs to link from build system like cmake or msbuild project. I believe there are reasons behind this ( I just found about Auto-linking).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s