문제

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?

도움이 되었습니까?

해결책

#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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top