【发布时间】:2016-07-21 18:51:28
【问题描述】:
我使用的是 CCS v6,出现结构语法错误。
typedef struct _mem_ptr_t
{
struct _mem_ptr_t *next; ///< Next pointer in memory
uint8 alloc; ///< Allocated
struct mmem mmem_ptr; ///< The actual pointer to the pointer to the mem block
} mem_ptr_t;
struct mmem {
struct mmem *next;
unsigned int size;
void *ptr;
};
以上代码是原始状态。但有一个错误。 "#71 不完整类型是不允许的"
所以,我更改了代码“struct mmem mmem_ptr;”->“struct mmem *mmem_ptr;” 当我编译时,那部分就通过了。
但是另一部分发生了错误。
if ((mem_ptr = mac_scan_alloc()) != NULL) {
memcpy(&SCAN_ENTRY(mem_ptr)->oord_addr, src_addr, sizeof(address_t));
SCAN_ENTRY(mem_ptr)->superfrm_spec = superframe_spec;
SCAN_ENTRY(mem_ptr)->coord_pan_id = src_pan_id;
SCAN_ENTRY(mem_ptr)->channel = channel;
}
#define SCAN_ENTRY(m) ((pan_descr_t *)MMEM_PTR(&m->mmem_ptr))
出现错误“#133 expression must have pointer-to-struct-or-union type”
我已经看过关于这个问题的相关问题。但我无法理解解决上述问题。 Expression must have pointer to struct or union error
我应该如何修复我的代码来解决这个问题?
【问题讨论】:
-
SCAN_ENTRY的定义? -
@EugeneSh.:它已经发布了。无论如何,
#define SCAN_ENTRY(m) ((pan_descr_t *)MMEM_PTR(&m->mmem_ptr))可能患有过多的&符号。 -
对.. 但是为什么在之后使用它呢?
-
@EugeneSh.:这实际上是一个真的好问题......
-
哦,对不起。这只是混合代码。 SCAN_ENTRY 位于头文件!