Who know that how to get the current line number of a program? And which API
in C++ and C can implement this ?
Thanks
Hi!
Actually, at runtime line numbers are of no meaning - all
that gets executed is the assembly generated by your C/C++
compiler. However, the C/C++ preprocessor inserts the
current line wherever you insert __LINE__ into your code.
Best regards
Stefan
The line number should be generated in the compiling time. Therefore, we
may get it by some macros. If you want to retrieve the line number, you can
use the __LINE__ macro.
e.g.
printf("%d", __LINE__);
The macro for file names is __FILE__
Hope this help.
-Dave