Sign in to follow this  

Get line number in MSVS 2003

This topic is 4401 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

Hi there! I have a little question. Is possible to get the line, where was thrown the exception and return the number of this line in exception? thx for help

Share this post


Link to post
Share on other sites
This information is available through the C preprocessor if you are using C++, by using the __LINE__ macro (which is an integer equal to the line it is on). Pass this information to the exception constructor to propagate it.

If you run the program with an attached debugger, the program will stop once an unhandled exception is thrown and show you where it was thrown from. This works in both C++ and C#.

Share this post


Link to post
Share on other sites
Additionally, the __FILE__ macro gives you the filename of the source file the aforementioned line is in.

Illco

Share this post


Link to post
Share on other sites

This topic is 4401 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this