Storing in ROM instead of RAM

General discussion on Visual GLCD Software.
Post Reply
Author
Message
beastdevices
Posts: 4
Joined: 15 Dec 2010 11:12

Storing in ROM instead of RAM

#1 Post by beastdevices » 03 Jan 2011 02:48

I am having problem with the compiler when i try to declare pointers to
constants

when i have
*const char word1 = 'H';//{'W','R','I','T','E'};
// GLCD menu messages*
* unsigned char* message=&word1;*
it gives me an error " operator & is not applicable to these operands
'word1'

it is important so i could store strings in ROM instead of RAM.

When i tried the same in AVR code vision, it gave me no errors.

Please help

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Storing in ROM instead of RAM

#2 Post by filip » 18 Jan 2011 12:15

Hi,

You can declare a pointer to a constant like this :

Code: Select all

const char word1[] = {'W','R','I','T','E'};   // word1 is a constant array of char
const char *message = &word1;                 // message is a pointer to constant char, contains the starting address of the word1

void main(){
  ...
}
For more information on this subject, please read the Pointers, Pointer Constants and Pointer Arithmetic sections of the help file.

Regards,
Filip.

Post Reply

Return to “Visual GLCD General”