I have a native C++ program that uses "event queues" to execute functions on different threads. I allocate an "event" class on the heap, and put it on one of my threads' queues for execution.
It all works great, but it's very difficult to trace back the origin of these "events". I would like each "event" to store some information pertaining to where it came from. Right now I use intrinsic _ReturnAddress() for that, but I would also like to have the file name string and line number. I'm fine with using macros to schedule my "events".
Of course I don't want to pay the price for having these strings.
Is there any way of having the preprocessor build up and dump to file a map of "id" => "file,line", where the "id" would be some unique number incremented each time my macro gets expanded? I could store that id as my origin.
Or maybe compute a very short hash of the file name so I could use that at run time?
Any ideas are welcome.