I'm trying to assign a string to a char value from a struct
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;
my function is:
static inline char blah_get_param_char (blah_param_t* param_p)
{
return (((blah_param_char_t*)param_p)->param_val);
}
And the offending code that kicks this all off is:
((blah_param_char_t*)new_param_p)->param_val = value;
where value is "blah"
Which give me a warning: return makes integer from pointer without a cast
Now for integers it works:
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);
}
Any help would be really appreciated!
if you want to return the first character of the string from the function blah_get_param_char
then use *(((blah_param_int_t*)param_p)->param_val)
instead of (((blah_param_char_t*)param_p)->param_val);
Or, if you want to return the entire string then return as pointer ( char*
) to the string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.