What is it used for?

#pragma comment 

    3 answers 3

    Perhaps it is worth giving examples:

     // автоматически залинкует libname.lib #pragma comment( lib, "libname.lib" ) // автоматически залинкует emapi.lib #pragma comment( lib, "emapi" ) // при вызове линкера будет использован дополнительный параметр /include:__mySymbol #pragma comment( linker, "/include:__mySymbol" ) // Строка "Compiled on ДАТА-КОМПИЛЯЦИИ at ВРЕМЯ-КОМПИЛЯЦИИ" будет записана в ЕХЕ файл // ни на что влиять не будет, но будет видна в ЕХЕшнике в виде текста. #pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ ) // То же самое #pragma comment( user, "Ваша строка, просто будет болтаться в EXE файле" ) // В ЕХЕшник будет записано имя и версия компилятора. Ни на что не влияет // но можно будет потом посмотреть. #pragma comment( compiler ) 

    MSDN also says that

      #pragma( exestr, "ваш комментарий" ) 

    outdated and in future versions of the compiler will not be supported.

    Instead, you can use:

     #pragma( user, "ваша строка коммента" ) 

      For Visual Studio puts:

      • compiler version (compiler)
      • string (exestr),
      • library to search (lib)
      • option for the collector (linker)
      • arbitrary comment

      in the object file.

        It should be noted that

         #pragma comment 

        "trick" exclusively Microsoft'ovskogo compiler. GCC does not know how. Thank you for that.