#pragma 预处理指令

Linux C 编程一站式学习

#pragma 预处理指示供编译器实现一些非标准的特性,C 标准没有规定 #pragma 后面应该写什么以及起什么作用,由编译器自己规定。有的编译器用 #pragma 定义一些特殊功能寄存器名,有的编译器用 #pragma 定位链接地址,本书不做深入讨论。如果编译器在代码中碰到不认识的 #pragma 指示则忽略它,例如 gcc 的 #pragma 指示都是 #pragma GCC  ...这种形式,用别的编译器编译则忽略这些指示。

VC 可以用 #pragma comment 来指示链接的静态库,这个就比较神奇了,一般指定链接的静态库都是通过链接器的参数去指定,而这个却将它放到了代码中,例如:

#pragma comment( lib, "emapi" )

The following pragma causes the linker to search for the EMAPI.LIB library while linking. The linker searches first in the current working directory and then in the path specified in the LIB environment variable.

原文地址:https://www.cnblogs.com/rednodel/p/5992761.html