Passing Strings in CodevisionAVR

Id like to see how this CodevisionAVR compiler compares to the keil compiler, but I cant get it to compile a function where I pass a character string...

#define MSG_A " " #define MSG_B " "

void Update_LCD(char* first_line, char* second_line) { //Do Something }

void main (void) { Update_LCD("Hello", "World"); //Doesnt work Update_LCD( MSG_A MSG_B); //Doesnt work }

This compiles and works fine with the Keil, but with the CodevisionAVR I get a "function parameter #1 incompatible with its declaration" error. Is the way Im doing it violate some ANSI C rule, or does Codevision need to have it done differently?

Reply to
benn686
Loading thread data ...

Try making that (please note that this is untested and from memory)

void Update_LCD( char flash * first_line, char flash * second_line)

This is because the CodeVision compiler splits the memory address space into different sections and there is no way to have an generic pointer to any type of memory. You will can get more advice on the CodeVision yahoo group.

Kevin.

Reply to
Kevin Bagust

That did it!!! Thanks a bunch!

I'll also check out the codevision group see if anyone else has compared it with other compilers.

Cheers!

Reply to
benn686

CVAVR doesn't quite conform to ANSI C. In this particular case, it puts character literal strings in flash, and doesn't have generic memory pointers. Unqualified data pointers point to RAM.

You have two choices to make this work: 1) copy the literal strings into RAM buffers, and pass pointers to the RAM to UpdateLCD, or 2) modify Update_LCD so it works with flash strings, e.g.

void Update_LCD(char flash * first_line, char flash * second_line) { ///etc. }

This is all explained quite clearly in the manual. You might also want to join the yahoo group "codevisionavr," where several knowledgable people hang out, including the developer himself.

HTH, -=Dave

--
Change is inevitable, progress is not.
Reply to
Dave Hansen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.