global counter in application: bad practice?
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2010-05-12T18:47:31Z
Indexed on
2010/05/12
18:54 UTC
Read the original article
Hit count: 149
c++
|global-variables
In my C++ application I sometimes create different output files for troubleshooting purposes. Each file is created at a different step of our pipelined operation and it's hard to know file came before which other one (file timestamps all show the same date).
I'm thinking of adding a global counter in my application, and a function (with multithreading protection) which increments and returns that global counter. Then I can use that counter as part of the filenames I create.
Is this considered bad practice? Many different modules need to create files and they're not necessarily connected to each other.
© Stack Overflow or respective owner