global counter in application: bad practice?
- by Martin
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.