Re: Passing Strings in CodevisionAVR

Feb 01, 2006 3 Replies


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?

Try your prototype as: void Update_LCD(const char *first_line, const char *second_line);


A string constant is not modifiable but your original function prototype will imply to the compiler that the objects pointed to by the arguments may be modified by the function. Since a string literal like this will probably be created in, and remain in, non-modifiable memory in the AVR (i.e., flash) this is a good assumption.

Rich Webb Norfolk, VA

^ ^ I would expect a comma there unless there is a typo in copying.

I would check whether what you posted is a cut and paste of the code or a typed extract. If cut and paste my first port of call on ANY compiler would be to put the comma in.

Paul Carpenter | paul@pcserviceselectronics.co.uk PC Services GNU H8 & mailing list info For those web sites you hate

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: Also see

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required