Sardeep Lakhera
Sardeep Lakhera

Reputation: 319

Flag for gcc to turn off buffering of stdout?

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.

Upvotes: 0

Views: 450

Answers (1)

3Doubloons
3Doubloons

Reputation: 2106

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.

Upvotes: 3

Related Questions