1.#pragma alignment(这个我在网上找到的,不是很理解,暂做记录)
alignment pragma用于显示一条当前内存对齐(alignment)和枚举(enum)字节大小的消息。例如:
W8035: The alignment is 8 bytes, the enum size is 4 bytes
该消息必须在打开编译器选项”show general messages”或编译器开关”-wmsg”后才能显示。
2.#pragma anon_struct
#pragma anon_struct on 允许编译类中内嵌的匿名结构
#pragma anon_struct off 禁止编译类中内嵌的匿名结构
#pragma anon_struct on
struct S
{
int i;
struct // Embedded anonymous struct
{
int j ;
float x ;
};
S() { i = 1; }
};
#pragma anon_struct off
3.#pragma argsused
argsused pragma通常在定义一个函数前使用,用于屏蔽函数参数未使用的警告。例如:
#pragma argsused
int func(int a,int b)
{
++b;
return b;
}
如果不使用该pragma,编译器就会报类似”函数参数没有用到”的警告消息。
4.#pragma checkoption optionstring
checkoption pragma检查optionstring中包含的选项是否已设置。例如:
#pragma checkoption -a4 -b
如果没有设置,显示一个错误:E2471: pragma checkoption failed: options are not asexpected。