Jump to content
  • Advertisement
Sign in to follow this  
The C modest god

Unity Error details

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement


#define Error(message) debug_error(message, __FILE__, __LINE__)

void debug_error(const char * errmsg, const char * file, int line)
{
// Print Error Message here
}


Share this post


Link to post
Share on other sites
Is there no way to tell in which line and file a function is being called from within that method?
So I could get this information in one place and wont have to call __FILE__ and __LINE__ as paramters to my error method?
How did he print in which method the error occured?

Share this post


Link to post
Share on other sites
On some compilers there is also a __FUNCTION__ symbol that is the name of the function where it is used. So expanding on what Ximmer wrote:
    #define Error(message) debug_error(message, __FILE__, __LINE__, __FUNCTION__)

void debug_error(const char * errmsg, const char * file, int line, const char * function)
{
printf( "Error in function '%s' at line %d in '%s': %s\n",
function, line, file, errmsg };
}

void foo()
{
...
if ( x < 0 )
{
Error( "x is less than zero" );
}
...
That code might print a line something like this:

Error in function 'foo' at line 345 in 'bar.c': x is less than zero

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!