为什么我使用 gcc-arm-none-eabi 会收到此警告
why do i get this warning with gcc-arm-none-eabi
我收到以下警告:
/path/to/project/src/my_main.c:24:36: warning: pointer targets in initialization of 'const uint8_t *' {aka 'const unsigned char *'} from 'char *' differ in signedness [-Wpointer-sign]
对于以下行:
const uint8_t* REQUPDATE_WARNING = "{\"id\":\"warning\",\"value\":\"mcu_upd\"}\n";
其中 uint8_t
是:
(stdint.h):
#ifndef _UINT8_T_DECLARED
typedef __uint8_t uint8_t ;
#define _UINT8_T_DECLARED
(_default_types.h)
#ifdef __UINT8_TYPE__
typedef __UINT8_TYPE__ __uint8_t;
#else
typedef unsigned __INT8_TYPE__ __uint8_t;
#endif
为什么我会收到此警告以及如何删除它?
字符串字面量是字符数组,会衰减到 char *
您需要添加强制转换以抑制警告
const uint8_t* REQUPDATE_WARNING = (uint8_t *)"{\"id\":\"warning\",\"value\":\"mcu_upd\"}\n";
我收到以下警告:
/path/to/project/src/my_main.c:24:36: warning: pointer targets in initialization of 'const uint8_t *' {aka 'const unsigned char *'} from 'char *' differ in signedness [-Wpointer-sign]
对于以下行:
const uint8_t* REQUPDATE_WARNING = "{\"id\":\"warning\",\"value\":\"mcu_upd\"}\n";
其中 uint8_t
是:
(stdint.h):
#ifndef _UINT8_T_DECLARED
typedef __uint8_t uint8_t ;
#define _UINT8_T_DECLARED
(_default_types.h)
#ifdef __UINT8_TYPE__
typedef __UINT8_TYPE__ __uint8_t;
#else
typedef unsigned __INT8_TYPE__ __uint8_t;
#endif
为什么我会收到此警告以及如何删除它?
字符串字面量是字符数组,会衰减到 char *
您需要添加强制转换以抑制警告
const uint8_t* REQUPDATE_WARNING = (uint8_t *)"{\"id\":\"warning\",\"value\":\"mcu_upd\"}\n";