This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: printf before main?


On Tue, Mar 23, 2010 at 4:20 PM, Brendan Miller <catphive@catphive.net> wrote:
> 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.

In general yes. Though I think the C++ standard is ambiguous about the
status of iostreams before main.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]