1 year, 1 month 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

1 year, 1 month ago.

Just following your thread - - this makes no sense. It should be char

1 year, 1 month 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.