I was learning a winsock client server program and came up through #pragma comment(lib,"ws2_32.lib")
. Understood its need here. But what are the other instances I can use it and why do I need to use it?
Asked
Active
Viewed 1,336 times
2

Angew is no longer proud of SO
- 167,307
- 17
- 350
- 455

WIN_SOM_LIV
- 160
- 2
- 9
-
It is already extensively documented in the [MSDN library](http://msdn.microsoft.com/en-us/library/d9x1s805.aspx), no need to repeat it here. – Hans Passant Sep 06 '13 at 11:07
1 Answers
2
#pragma
's are implementation defined compiler commands.
That means, each compiler could treat or support pragmas in a different way.
They are used for example for generating user defined warnings or errors as with
#pragma warning WARNINGMSG
or #pragma error ERRORMSG
or as include guard with #pragma once
at the top of a headerfile.
What #pragma comment
is used for, you can find nice explained here:
What does "#pragma comment" mean?
But after all, I would advise you to avoid pragmas as far it is possible, because as they are almost all, implementation defined, your code will be limited in portability if you use them.