我对这个问题完全不知所措,我甚至不知道在我的问题中应该包括什么.
当我将一个常量转换为指针时,我的(.data+.bss+.noinit)部分增长了1K,超过了ATmega328P的容量.
PK16_TABLE_T* pk16_find_table_by_index(PK16_T* p_pkg, SIZE_T index)
{
SIZE_T offset;
PK16_TABLE_T* p_table;
p_table = (PK16_TABLE_T*) 0;
return p_table;
}
如果我转换指针,那么数据大小保持不变,而不是增加1K:
PK16_TABLE_T* pk16_find_table_by_index(PK16_T* p_pkg, SIZE_T index)
{
SIZE_T offset;
PK16_TABLE_T* p_table;
p_table = (PK16_TABLE_T*) &offset;
return p_table;
}
我从哪里开始调试呢?你还需要看到什么才能理解可能发生的事情?
/** A single entry in a PK16 package. */
typedef struct {
/** Null-terminated string representing the path of this entry. */
CHAR_T path[PK16_MAX_PATH_LEN];
/** Index into the package data buffer of the start of this entry's data. */
U16_T head;
/** Length in bytes of this entry's data in the data buffer. */
U16_T len;
/** CRC32 of this entry's path + data. */
U32_T crc;
} PK16_TABLE_T;