N
Neil
Question
should this cast be necessary?
The Compiler is 8 Bits the ints are 16 bits.
The Code is for a ring buffer
It does not work without the cast in this compiler.
I have seen it work else where without it.
Which way is right (or should it matter at all?)
Thanks Neil
unsigned char t_in;
unsigned char t_out;
/*----------------------------------------------------------------*/
bit com_putchar (unsigned char c)
{
/*If the buffer is full, return an error value.*/
if ((TBUF_SIZE - (unsigned char)(t_in - t_out)) <= 2)
return (1);
/* More Code */
/* More Code */
/* More Code */
/* More Code */
return (0);
}
should this cast be necessary?
The Compiler is 8 Bits the ints are 16 bits.
The Code is for a ring buffer
It does not work without the cast in this compiler.
I have seen it work else where without it.
Which way is right (or should it matter at all?)
Thanks Neil
unsigned char t_in;
unsigned char t_out;
/*----------------------------------------------------------------*/
bit com_putchar (unsigned char c)
{
/*If the buffer is full, return an error value.*/
if ((TBUF_SIZE - (unsigned char)(t_in - t_out)) <= 2)
return (1);
/* More Code */
/* More Code */
/* More Code */
/* More Code */
return (0);
}