Why Does The Mac Version Of C Debugging Have printf Delay While On Windows It Works Fine #10369
Unanswered
Changho (andychyou)
asked this question in
Q&A
Replies: 2 comments
|
Andrew Wang (@WardenGnaw) Do you know about this? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have been facing the problem of printf() function delaying to show the outputs on the console. For example, when I have the program on a breakpoint in the printf(“hello world”) line and step over, the “hello world” doesn’t show up right after the line is executed. It is very weird as although the printf is executed, the output doesn’t show up on console right away.
It seems that I am not the only one witnessing this problem. Down below is the link to another user demonstrating what the problem looks like. He thinks the delay is due to the cache waiting.
https://www.youtube.com/watch?v=wKjFVyDbSpA&t=9m42s
But the funny thing is, if I have an ‘\n’ at the end of the string, it works fine. Meaning, executing printf(“hello world”) outputs nothing while printf(“hello world\n”) does print right away.
I don’t understand why this only happens on my Mac. On my WIndows machine, the printf will always return the output on the console right after execution. My current only guess on why the difference is because on Windows I use mingw64 and on Mac clang lldb for debugging. But it is so weird that if it is the nature of lldb with the printf cache delay why does it only happen on VS Code and not on XCode? On XCode it works fine.
I would appreciate if anyone could explain to me on why there is an output delay and if possible, how to fix it.
Here are some screenshots for reference.

Mac with '\n'
Mac without '\n'Windows working fine
All reactions