当前位置:网站首页>assert _Aligns
assert _Aligns
2022-07-26 02:23:00 【处女座程序员的朋友】
宏assert的定义依赖于标准库不定义另一个宏NDEBUG.
若NDEBUG 在包含了<assert.h>的源代码中的点定义为宏名,则assert不做任何事。
若不定义NDEBUG,则assert将其参数(必须拥有标量类型)与零比较相等,若相等,则assert在标准错误输出上输出实现指定的诊断信息,并调用abort。诊断信息要求包含表达式的文本,还有标准宏 _FILE_、_LINE_以及预定义变量_func_的值。
参数
condition --标量类型表达式
返回值
(无)
示例:
#include<stdio.h>
#include<assert.h>
#include<math.h>
int main(void)
{
double x = -1.0;
assert(x>=0.0);
printf("sqrt(x) = %f\n",sqrt(x));
return 0;
}
_Aligns
出现于声明语法中,作为修改声明对象对齐要求的指定符。
表达式:任何值为合法对齐或零的整数常量表达。
类型:任何类型名称
_Aligns 只能在声明不是位域,且不拥有寄存器存储类的对象时使用。它不能用于函数参数声明,也不能用于 typedef。用于声明时。设置被声明对象的对齐要求为:
1)表达式的结果,除非它是零。
2)类型的对齐要求,即设置为 _Alignof(type)
示例:
#include<stdalign.h>
#include<stdio.h>
//每一个 struct sse_t类型的对象会在16字节边界对齐。
struct sse_t
{
aligns(16) float sse_data[4];
};
//这种struct data 的每一个对象都会在128字节边界对齐
struct data{
char x;
alignas(128) char cacheline[128]; // 过对齐的char数组对象;
};
int main(void)
{
alignas(2048) struct data d; //此 struct data 的实例会更严格地对齐;
}
存储类指定符
auto -自动存储期与无链接
register-自动存储与无链接,不能取这种对象的地址
static 静态存储与内部链接(除非这块作用域)
extern-静态存储期与外部链接
静态存储期:存储是整个程序的执行过程。
边栏推荐
- (CVPR 2019) GSPN: Generative Shape Proposal Network for 3D Instance Segmentation in Point Cloud
- I.MX6UL核心模块使用连载-nand flash读写测试 (三)
- Pinia的数据持久化插件 pinia-plugin-persist
- 【红队】ATT&CK - 利用BITS服务实现持久化
- 19_ Request forms and documents
- numpy.sort
- The third question of leetcode 302 weekly Games -- query the number with the smallest k after cutting the number
- scipy.sparse.csr_matrix
- [2021] [paper notes] 6G technology vision - otfs modulation technology
- A pluggable am335x industrial control module onboard WiFi module
猜你喜欢
随机推荐
1. Mx6ul core module serial WiFi test (VIII)
ERROR: could not extract tar starting at offset 000000000000020980+9231072+2
prometheus+blackbox-exporter+grafana 监控服务器端口及url地址
Bo Yun container cloud and Devops platform won the trusted cloud "technology best practice Award"
1205 Lock wait timeout exceeded; Try restarting transaction processing
Project management: lean management method
Manifold learning
Design and driver transplantation of matrix keyboard circuit of Ti am335x industrial control module
Is the securities account presented by qiniu true? How to open it safely and reliably?
Handling process of the problem that the virtual machine's intranet communication Ping fails
18_请求文件
MySQL(4)
博云容器云、DevOps 平台斩获可信云“技术最佳实践奖”
17. Reverse the linked list
记录之目标检测NMS(非极大值抑制)
1. Mx6ul core module uses serial EMMC read / write test (IV)
19_ Request forms and documents
TCP三次握手四次挥手
The third question of leetcode 302 weekly Games -- query the number with the smallest k after cutting the number
[cloud native] 4.1 Devops foundation and Practice








