This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using sprintf and the char *restrict warning ...

Hi,

I am relatively new to the Keil / ARM development environment though have been programming microcontrollers and C for a few years now (though only in an amateur capacity :).

I am using sprintf to format a string for display on an LCD (though the same thing happens when sending the string over the serial port as well) and am getting a warning:

warning: argument of type "unsigned char *" is incompatible with parameter of type "char *restrict"

Everything works ok when I ignore this warning but ignoring these warnings doesn't sit well (especially as I don't really understand it). I get that "restrict" is a new keyword feature in C99 to enable compiler optimisations and it probably doesn't matter too much for the simple applications I am creating, but I would like to know if this is implemented in the ARM compilation toolchain and, if so, how I can use it. A snippet of my code is below:

// initialise some local values and the display buffer
uint32_t val;
static unsigned char disp_buffer[21];

// read the global variables to the local values
val = global_val;

// do string formatting before lcd display
sprintf(disp_buffer, "Value:   %4d", val);
GLCD_DisplayString(6, 0, 1, disp_buffer);

Thanks for any help you can give,

Alex

0