I’m working on a PIC 18f4685 using MPLabs C18 C-compiler and I’m having issue when I try and create an array of phrases that I want to print out to my LCD.
If I use Codeblocks with gcc and enter this code it prints out what I expect to the console…test1 test2 test3 test4:
char *test[]={"test1","test2","test3","test4"};
printf("%s %s %s %s\n",test[0],test[1],test[2],test[3]);
However, if I use this code in C18:
char *phrase[]={"test1","test2"};
I get warnings saying type qualifier mismatch in assignment and when I program the chip it spits out garbage to the LCD, which I kinda expected it would do.
What is the proper way to declare my phrases because something is obviously incorrect?
Apparently string literals are
rom const char[N]in MPLab C. So you need to declare your object like this:In MPLAB C18 C COMPILER USER’S GUIDE, there is a chapter named ISO DIVERGENCES (2.7) and 2.7.3 refers to string literals.
From 2.7.3: