printf before main?

Brendan Miller catphive@catphive.net
Tue Mar 23 20:20:00 GMT 2010


Is it safe to call printf family functions, or other streams
functionality before main? In other words, in global C++ constructors,
or functions with __attribute__((constructor))?

I'm wondering if any buffers for standard output are being allocated
during that phase... I need to do some output potentially before main
for logging purposes, and I'm wondering if I'd better off calling
write directly.

Brendan



More information about the Libc-help mailing list