linux - Flushing stdout messages of c/c++ based executable -


my question general , doesn't relate specific debugging scenario.

when program terminate unexpectedly (panic, memory corruption, access violation etc... ) , recent stdout messages doesn't appear on screen, though occurred prior termination.

that's because stdout messages first being written buffer erased upon termination without being written stdout in advance.

my question whether there's generic option flush debug messages in c/c++ code before program terminate unexpectedly ? (i prefer using generic compiler configuration rather ad-hoc solution specific implementation such std::cout - if there's such option, i'd happy know if it's common gcc , g++)

note : assume when flushing buffer each new arriving message, damage performance. however, it's meant debug version.

thanks

try setvbuf set no buffer

setvbuf(stream, null, _ionbf, 0) 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -