我正在尝试将字符串分配给结构中的 char 值
typedef struct blah_param_s {
struct blah_param_s* param_next;
blah_param_type_t param_type;
} blah_param_t;
typedef struct blah_param_char_s {
blah_param_t param_hdr;
char* param_val;
} blah_param_char_t;
我的功能是:
static inline char blah_get_param_char (blah_param_t* param_p)
{
return (((blah_param_char_t*)param_p)->param_val);
}
启动这一切的违规代码是:
((blah_param_char_t*)new_param_p)->param_val = value;
值是“blah”的地方
这给了我一个警告: return 从没有强制转换的指针中生成整数
现在对于整数它可以工作:
typedef struct blah_param_int_s {
blah_param_t param_hdr;
uint32_t param_val;
} blah_param_int_t;
static inline uint32_t blah_get_param_int (blah_param_t* param_p)
{
return (((blah_param_int_t*)param_p)->param_val);
}
任何帮助将非常感激!