Skip to main content
GameDev.net gamedev.net
🔒 Locked

Error Logging

Started by Running_Wolf Apr 23, 2006 at 4:56 PM 0 replies 600+ views
Original Post
Running_Wolf
Running_Wolf
I've seen it where an error log contains the source file name, line number, etc where the error took place. I have been able to figure that part of the error simply includes what file it is in, but since line numbers change constantly, how is that found and output?
L.I.G. == Life Is Good
rip-off
rip-off
Assuming c/c++.


The preprocessor will change __LINE__ and __FILE__ to values which show up the actual file and line numbers.

So your log could be like this:

void log( const std::string &file, int line, const std::string &message ){   //output;}#define log(M) log(__FILE__,__LINE__,(M) )


Now we can use log("Hello World"); and let the compiler do the hard work for us.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.