10 years, 11 months ago.

fputc definition

I intend to do a port of some of the mbed library to another device so that I can reuse some libraries that I've written for mbed. The two libraries that are of most interest are SPI and Serial.

I can understand all of the workings of the SPI library and believe I can implement it on the other device. I'm struggling however with the Serial library. In the Stream library which Serial inherits from, the putc member function calls std::fputc

int Stream::putc(int c) {
    fflush(_file);
    return std::fputc(c, _file);
}

Somehow fputc calls the Serial::_putc member function, but I can't find a definition of fputc anywhere in the mbed library. Please could someone tell me where the c code for fputc is or how the Serial::_putc method is called from it?

Thanks, Tim

Question relating to:

2 Answers

10 years, 11 months ago.

fputc is part of the C standard library.

You can find its documentation here.

As an example, you can find the newlib implementation here.

HTH, Emilio

Accepted Answer
Tim Barry
poster
10 years, 11 months ago.

Thanks Emilio