0

Is there any flag for gcc or g++ that turns the buffering off for stdout? Like python -u turns off buffering of stdout ,stdin and stderr in python.

perror
  • 7,071
  • 16
  • 58
  • 85
Sardeep Lakhera
  • 309
  • 4
  • 15

1 Answers1

3

GCC, as a compiler, only generates an executable. It has no real knowledge of buffering or even of streams. Only the C runtime knows what your stdout and stderr are. You need to tell the C runtime, at obviously runtime, to disable buffering.

By comparison, the Python runtime is an interpreter. As an interpreter, it is the one to set up your streams and can disable the buffering if you ask it to.

3Doubloons
  • 2,088
  • 14
  • 26