Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MPLAB XC8 Warning meaning ??

Status
Not open for further replies.

Mamdouh1

Newbie level 3
Joined
May 8, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
38
Hi everybody .
what is this warning meaning in MPLAB XC8 and how avoid it ??

newmain.c:63: warning: (359) illegal conversion between pointer types

The code cause this warning come from :

Code:
   LCD_Out_Cp(">>>");

the function is :

Code C - [expand]
1
2
3
4
5
void LCD_Out_Cp(unsigned char *Str)
    {
         while(*Str)
                  LCD_Chr_Cp(*Str++);
     }



thanks for help .
 
Last edited by a moderator:

you are assigning address of a constant string to non constant char pointer. That is why compiler gave this warning. Use below code to avoid this warning

#pragma warning disable 359
 

Thanks for reply ,
I get another warning from this line :

Code:
 LCD_Out("Sec L",2,3);

newmain.c:43: warning: (359) illegal conversion between pointer types
pointer to const unsigned char -> pointer to unsigned char

the function is :

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void LCD_Out_Cp(unsigned char  *Str)
{
    while(*Str)
        LCD_Chr_Cp(*Str++);
}
 
void LCD_Out(unsigned char *Str1,unsigned char raw,unsigned char column)
{
    if(raw==1)
    {
       LCD_Cmd(0x80+column);
       LCD_Out_Cp(*Str1);
    }
    if(raw==2)
    {
        LCD_Cmd(0xC0+column);
        LCD_Out_Cp(*Str1);
    }
}

 
Last edited by a moderator:

For all string transmissions if you have const char* input i.e. input like "Hello World" instead of pointer use pointer type cast to resolve the issue, for e.g.

Code:
LCD_Out_Cp((unsigned char*)"Hello World!");

I see that your Line 17 is wrong, you need to pass a pointer to LCD_Out_Cp and hence only Str1 not *Str. You are using *Str in your LCD_Out_Cp function which means that Str is an address, so use Str not *Str and if you get warnings or errors about pointer type conversions then use type casting for pointers.

Also, use this instead

Code:
LCD_Out((unsigned char*)"Sec L", 2, 3);
 
For pointer concept
*str returns value, str returns address of the value.
So allways keep in mind that print the value and increase the address and print the value and so on....

XC8 compiler creates errors for pointers, but C18 compiler does'nt.
Thanks for reply ,
I get another warning from this line :

Code:
 LCD_Out("Sec L",2,3);



the function is :

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void LCD_Out_Cp(unsigned char  *Str)
{
    while(*Str)
        LCD_Chr_Cp(*Str++);
}
 
void LCD_Out(unsigned char *Str1,unsigned char raw,unsigned char column)
{
    if(raw==1)
    {
       LCD_Cmd(0x80+column);
       LCD_Out_Cp(*Str1);
    }
    if(raw==2)
    {
        LCD_Cmd(0xC0+column);
        LCD_Out_Cp(*Str1);
    }
}

 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top