Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 5 months ago.
Why Serial::getc returns integer ?
I uses mbed os5. getc means that get char.
However the document says getc returns integer. And argument of putc is integer, too
Why getc returns integer and argument of putc is integer?
2 Answers
5 years, 5 months ago.
Only the bottom 8 bits will be valid but the variable type is an integer. This also avoids the issue that for some compilers char defaults to signed and on others it defaults to unsigned.
It's a little odd but it's not a big issue, the compiler will handle implied casts to/from a char as needed.