0

Possible Duplicate:
Gettin line number of the called function

I'm debugging, and it's extremely useful for me to find a function that returns the position of this function in the code. More precisely, is there a function that can return the line number of the function in the code? For example, if I call f() in line x, the returned value is an integer x.

Thanks, Michael

Community
  • 1
  • 1
  • 7
    What kind of construct are we talking about? – Mr Lister Jun 29 '12 at 16:17
  • 1
    what? are you referring to a 2D array – Eamonn McEvoy Jun 29 '12 at 16:17
  • 1
    show some code. this question is nonsensical for lack of context – sehe Jun 29 '12 at 16:18
  • 1
    just call `std::usher()` and it will tell you which row to use. – Captain Obvlious Jun 29 '12 at 16:24
  • 4
    Are you perhaps looking for the `__LINE__` macro? http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html – Olumide Jun 29 '12 at 16:24
  • 3
    There should be a badge for editing a closed question with -5 and getting it back to 0 and reopened. – Mysticial Jun 29 '12 at 16:40
  • There should be a badge for editing a closed question with -5 and getting it back to 0 and reopened, which is soon after closed again. – Almo Jun 29 '12 at 16:45
  • Except it *is* a dupe. Anyway, the solution is to use a platform-specific stack backtrace. There is no way to do it semantically. Well, except by adding a `line_number` argument to `f()`, defining `#define F_MACRO(fn, ...) fn( VA_ARGS, __LINE__ )`, and always calling the macro… and the macro is specific to non-nullary functions… – Potatoswatter Jun 29 '12 at 16:48

0 Answers0