【发布时间】:2016-06-23 10:32:52
【问题描述】:
我正在做一个练习,这是一段代码:
typedef struct node
{
size_t size;
struct node *next;
} node_t;
byte heap[SIZE];
node_t *node_list;
void heap_init()
{
node_list = (node_t*) heap;
node_list->size = SIZE;
node_list->next = NULL;
}
但我在理解这条线时遇到了一些麻烦:
node_list = (node_t*) heap;
【问题讨论】:
-
题外话:和平->一块。
-
这是未定义的行为,因为
heap可能未正确对齐node_t。它也违反了严格的别名规则