[LLVMdev] STDIN/STDOUT/STDERR

Joerg Sonnenberger joerg at britannica.bec.de
Mon Mar 24 17:10:43 PDT 2014


On Mon, Mar 24, 2014 at 07:32:07PM -0400, William Moses wrote:
> How would one be able to represent stdin/stdout/stderr in llvm (using the
> api) for use in functions such as fputs?

stdin / stdout / stderr are macros on many systems and expand either to
separate pointers or members of a single global array. The only way that
will work in general is to use stdio.h.

> One could use the external function fdopen to generate the FILE* and store
> it in a global variable, but I would be willing to guess that there is a
> more efficient way.

fdopen will not give you another reference to the pre-defined streams,
but a separate FILE object with its own buffer etc.

Joerg



More information about the llvm-dev mailing list