On Thu, 2008-01-24 at 15:46 +0000, Paul Herring wrote:
> On Jan 24, 2008 3:19 PM, Christopher Carver
> <[EMAIL PROTECTED]> wrote:
> > I have an application where I want to generate unique error codes
> > depending on the path the code takes (call stack).
> 
> [snip]
> 
> Sounds like what a lot of other tools out there do during development
> work. Sounds like you want something for production however. Not
> something I'd advocate. However...
> 
> Have a global variable, and (re-)hash it every time at the start of a
> function call (or wherever in your code you want a path to be noted)
> with either a fixed number or the current line number in that file.
> The eventual hash should give you some sort of indication of the path
> taken.
> 
> static hash_val;
> void rehash(long l_val){
> // your hash function here to change hash_val with l_val)
> }
> 
> int foo(...){
> rehash(__LINE__);
> // body of foo();
> }
> 
> float bar(...){
> rehash(__LINE__);
> // body of bar();
> }
> 
> ... etc.
> 
> Generating the lookup table will not be fun however.
> 
> -- 
> PJH
> 
> http://shabbleland.myminicity.com
> 
> 
> 
>  

Yeah I need unique error code ids based on code paths because the code
can self correct by traversing a different path. While I appreciate your
suggestion you are right, building a look up table would be tedious with
that implementation and a new table be made per build. 

Thank you for the suggestion. I might have to hit up some graph theory
books.

Reply via email to