Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

const char*

Status
Not open for further replies.

maria258

New Member
I am using mplab hitech pic16f877a, and am trying to compile these:

1. void PutLogo(const char * logo)
2. void PutMessage(static char *Message)
3. PutMessage(( char*)"\x16\x38\x18Graphic demo.");

Is there any other way to change these around so that the compiler can build this program without errors? I tried to find an alternative using the maual but couldnt understand what to do.
thanks
Maria
 
You need to cast it to a rom pointer,

PutMessage((const char *) "\x16\x38\x18Graphic demo.");

Should compile ok.

I'm not sure how the logo is defined so not able to help at the moment.

Mike.
 
hi pommie, im using the code, the one you sent me cos i know this works fine. i removed all the rom but still it doesnt compile. it gives these errors:
Error [984] C:\PROJECT\POMMIE.c; 209.1 type redeclared (for no1)
Error [1098] C:\PROJECT\POMMIE.c; 209.1 conflicting declarations for variable "PutLogo" (C:\PROJECT\GLCD.h:37) (for no1)
Error [252] C:\PROJECT\POMMIE.c; 209.1 argument 0 conflicts with prototype (for no1)
Error [192] C:\PROJECT\POMMIE.c; 361.17 undefined identifier "Logo" (for PutLogo(( char*)Logo);)
 
You will need to change the functions and any prototypes as well,

void PutMessage(const char *Message){

Mike.
 
You open GLCD.c and change

void PutMessage(static char rom *Message){

to

void PutMessage(const char *Message){

and in main you change any

PutMessage((rom char*)"\x16\x38\x18Graphic demo.");

to

PutMessage((const char*)"\x16\x38\x18Graphic demo.");

Mike.
 
Use the original code and add another process

Code:
char messbuff[20];

sprintf(messbuff, " message to send");
putmessage(messbuff);

Then you don't have to worry about casting...

Ian

It's far more efficient and uses less ram to pass a pointer to the ROM copy of the string. Plus, the routine is written to expect a ROM pointer and, as you know, RAM and ROM pointers are two very different animals.

Mike.
 
I am using mplab hitech pic16f877a, and am trying to compile these:

1. void PutLogo(const char * logo)
2. void PutMessage(static char *Message)
3. PutMessage(( char*)"\x16\x38\x18Graphic demo.");

Is there any other way to change these around so that the compiler can build this program without errors? I tried to find an alternative using the maual but couldnt understand what to do.
thanks
Maria

What was the original error using the above?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top