<div dir="ltr">The high-level answer is that library code shouldn't hardcode output paths, including "-" and including using llvm::outs(). Library code should (in general) instead accept an ostream in its API and write to wherever it is being asked to write. If this is followed, the only place in any program using llvm::outs() is code which is not part of a "library" -- i.e. it is the "main" code, and it should only do so if it is a program which doesn't open file names which could be "-".<div>
<br></div><div>Do you have a use-case where this restriction is too restrictive?<br><div><div><br></div><div>As a random aside, a more aggressive answer could be that "-" is a kind of hack, and that it would be a better approach to use /dev/stdout and /dev/stdin instead of "-", because they wouldn't require special-case logic. Unfortunately, this may not be sufficiently portable.<br>
<div><br></div><div>Dan</div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 14, 2013 at 8:28 AM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br>
<br>
When I run the below example, it results in :-<br>
<br>
hello<br>
world<br>
LLVM ERROR: IO failure on output stream.<br>
<br>
Testcase :-<br>
<br>
#include <llvm/Support/raw_ostream.h><br>
<br>
int fn() {<br>
  std::string errorInfo;<br>
  llvm::raw_fd_ostream out("-", errorInfo);<br>
  out << "world\n";<br>
  return 0;<br>
}<br>
int main(int argc, char **argv) {<br>
  llvm::outs() << "hello\n";<br>
  fn();<br>
  return 0;<br>
}<br>
<br>
I tried to fix this by making llvm::outs(), not close the stdout<br>
descriptor, but I think its wrong. Recommendations ?<br>
<br>
Thanks<span class="HOEnZb"><font color="#888888"><br>
<br>
Shankar Easwaran<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</font></span></blockquote></div><br></div>