5.14 属性声明:mode

5.14 属性声明:mode

属性声明:mode

显式指定数据类型所占的字节数

使用示例

typedef int s8 __attribute__((mode(QI)));
typedef unsigned int us8 __attribute__((mode(QI)));

mode属性参数

属性参数描述
QIAn integer that is as wide as the smallest addressable unit, usually 8 bits.
HIAn integer, twice as wide as a QI mode integer, usually 16 bits.
SIAn integer, four times as wide as a QI mode integer, usually 32 bits.
DIAn integer, eight times as wide as a QI mode integer, usually 64 bits.
SFA floating point value, as wide as a SI mode integer, usually 32 bits.
DFA floating point value, as wide as a DI mode integer, usually 64 bits.

代码

#include<stdio.h>

typedef int s8 __attribute__((mode(QI)));
typedef int s16 __attribute__((mode(HI)));
typedef int s32 __attribute__((mode(SI)));
typedef int s64 __attribute__((mode(DI)));

typedef unsigned int us8 __attribute__((mode(QI)));
typedef unsigned int us16 __attribute__((mode(HI)));
typedef unsigned int us32 __attribute__((mode(SI)));
typedef unsigned int us64 __attribute__((mode(DI)));

typedef float f32 __attribute__((mode(SF)));
typedef float f64 __attribute__((mode(DF)));
int main(void)
{
	s8 i;
	printf("i: %d\n",sizeof(i));
	printf("%d\n",sizeof(s8));
	printf("%d\n",sizeof(s16));
	printf("%d\n",sizeof(s32));
	printf("%d\n",sizeof(s64));

	printf("%d\n",sizeof(us8));
	printf("%d\n",sizeof(us16));
	printf("%d\n",sizeof(us32));
	printf("%d\n",sizeof(us64));
	
	printf("%d\n",sizeof(f32));
	printf("%d\n",sizeof(f64));
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值