[code below, first context]
The context is to have a method applib_echo(const char *restrict, ...); that would allow me to print as much as possible during program life time.
The expected API would go like this:
// In main function:
int main(void)
{
applib_echo_init();
// whatever code here
applib_echo_dispose();
}
and in a code, it would go like this:
// some computations
applib_echo("Hello %s\n", "World");
// some other computations
Direct usage of printf wouldnt work, because I want that no prints happen if the second computation fails (for example, abort or exit)
one way, suggested by Nekro, is the open stdout in fully-buffered mode. I did not implement that one solution because I would need to make sure the BUFSIZ capacity is not reached anyway.