소스 검색

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 년 전
부모
커밋
d81b53817b
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  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;
     std::vector<GenericValue> args;
     Function *brainf_func = M.getFunction("brainf");
     Function *brainf_func = M.getFunction("brainf");
     GenericValue gv = ee->runFunction(brainf_func, args);
     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 {
   } else {
     WriteBitcodeToFile(Mod.get(), *out);
     WriteBitcodeToFile(Mod.get(), *out);
   }
   }