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.

[PIC] implicit signed to unsigned conversion

Status
Not open for further replies.

Ivan-Holm

Member level 5
Joined
Jun 3, 2010
Messages
84
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Location
Denmark
Activity points
1,894
why can't I write
Code:
  char Dispwrite( )
  {
      LCD_Text;
            for(int i = 0; i <= sizeof(lcdtext)-2; i++ )
           {
                LCD_E_ON;
                forsin(); //delay
                LCD_Data = lcdtext[i];
                forsin(); //delay
                LCD_E_OFF;
                forsin(); //delay
           }
  }
I get two warnings
init.c:61: warning: (355) implicit signed to unsigned conversion
init.c:70: warning: (343) implicit return at end of non-void function

the first is I use int and size-of data type I think.
the second is no return type or wrong return type,
have any suggestions ?

I use the free xc8 compiler on pic18f242
 
Last edited:

for your second warning, look that you started with "char Dispwirte(){" so you need to return a value, maybe add a "return 0;" before you finish the function?? but if you don't need a result (and if you don't need and argument) I suggest you to change the first line to "
Code:
void DispWrite(void)
"

for the first warning.... mmmm
I
It seems sizeof return an unsigned value... I suggest you to change i to unsigned int like "
Code:
for(unsigned int i = 0; i <= sizeof(lcdtext)-2; i++ )
" it seems larger but your number i will be a littler more efficent.
 
  • Like
Reactions: Ivan-Holm

    V

    Points: 2
    Helpful Answer Positive Rating

    Ivan-Holm

    Points: 2
    Helpful Answer Positive Rating
for your second warning, look that you started with "char Dispwirte(){" so you need to return a value, maybe add a "return 0;" before you finish the function?? but if you don't need a result (and if you don't need and argument) I suggest you to change the first line to "
Code:
void DispWrite(void)
"

for the first warning.... mmmm
I
It seems sizeof return an unsigned value... I suggest you to change i to unsigned int like "
Code:
for(unsigned int i = 0; i <= sizeof(lcdtext)-2; i++ )
" it seems larger but your number i will be a littler more efficent.

Thanks. the Unsigned works
I have try void to put in void before posting but it still get a warning "init.c:71: warning: (343) implicit return at end of non-void function" and Return 0; is a bad Idea when it is embedded Hardware.
 

Return 0; is a bad Idea when it is embedded Hardware.
Only when it is from the main() function and there is no OS to return to. If 'Dispwrite' was called as part of your program, which I assume it is, you should return a value. As it only seems to be writing to an LCD, I can't see why you can't make it a void function though.

The other thing to check if 'void' still gives an error is did you change the prototype to 'void'?

Brian.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top