Pārlūkot izejas kodu

BrainF example: fixing output buffering issue
Differential Revision: https://reviews.llvm.org/D27824

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292216 91177308-0d34-0410-b5e6-96231b3b80d8

Boris Ulasevich 8 gadi atpakaļ
vecāks
revīzija
d81b53817b
1 mainītis faili ar 4 papildinājumiem un 0 dzēšanām
  1. 4 0
      examples/BrainF/BrainFDriver.cpp

+ 4 - 0
examples/BrainF/BrainFDriver.cpp

@@ -166,6 +166,10 @@ int main(int argc, char **argv) {
     std::vector<GenericValue> args;
     Function *brainf_func = M.getFunction("brainf");
     GenericValue gv = ee->runFunction(brainf_func, args);
+    // Genereated code calls putchar, and output is not guaranteed without fflush.
+    // The better place for fflush(stdout) call would be the generated code, but it
+    // is unmanageable because stdout linkage name depends on stdlib implementation.
+    fflush(stdout);
   } else {
     WriteBitcodeToFile(Mod.get(), *out);
   }