EmbeddedRelated.com
Forums

Passing Strings in CodevisionAVR

Started by Unknown January 31, 2006
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?

I qualified it with  'const' in the prototype and the declaration but
it still reports the same incompatibility error.

BTW, the example code I posted had a typo... it should have had a comma
between the parameters.   Its just a general example of the scenario.

benn686@hotmail.com wrote:
> 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 > }
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.
benn686@hotmail.com wrote:
> > I qualified it with 'const' in the prototype and the declaration > but it still reports the same incompatibility error. > > BTW, the example code I posted had a typo... it should have had a > comma between the parameters. Its just a general example of the > scenario.
What is 'it'. What is the example code? What scenario? Google is NOT usenet. Most peoples view of the thread is much different from yours. You must always include sufficient context so that your article can stand by itself. Others may never have seen, or may never see, previous articles in the thread. To properly use the foully broken google usenet interface, see my sig below. Please read the referenced URLs. -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson More details at: <http://cfaj.freeshell.org/google/> Also see <http://www.safalra.com/special/googlegroupsreply/>
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!

On 31 Jan 2006 15:01:59 -0800 in comp.arch.embedded,
benn686@hotmail.com wrote:

>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?
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.