BitFreak
BitFreak

Reputation: 416

why do i get this warning with gcc-arm-none-eabi

I'm getting the below warning:

/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]

for the following line:

const uint8_t* REQUPDATE_WARNING = "{\"id\":\"warning\",\"value\":\"mcu_upd\"}\n";

Where uint8_t is:

(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

Why do I get this warning and how can I remove it?

Upvotes: 0

Views: 296

Answers (1)

0___________
0___________

Reputation: 67476

string literals are arrays of chars which decay to char *

You need to add the cast to suppress the warning

const uint8_t* REQUPDATE_WARNING = (uint8_t *)"{\"id\":\"warning\",\"value\":\"mcu_upd\"}\n";

Upvotes: 1

Related Questions