From: Bill Wendling
The use of #include <iostream> in library files is +hereby forbidden. The primary reason for doing this is to +support clients using LLVM libraries as part of larger systems. In particular, +we statically link LLVM into some dynamic libraries. Even if LLVM isn't used, +the static c'tors are run whenever an application start up that uses the dynamic +library. There are two problems with this:
+ +Old Way | +New Way | +
---|---|
#include <iostream> |
+ #include "llvm/Support/Streams.h" |
+
DEBUG(std::cerr << ...); |
+ DOUT << ...; |
+
std::cerr << "Hello world\n"; |
+ llvm::cerr << "Hello world\n"; |
+
std::cout << "Hello world\n"; |
+ llvm::cout << "Hello world\n"; |
+
std::cin >> Var; |
+ llvm::cin >> Var; |
+
std::ostream |
+ llvm::OStream |
+
std::istream |
+ llvm::IStream |
+
std::stringstream |
+ llvm::StringStream |
+