In the sake of debugging purposes, can I get the line number in C/C++ compilers? (standard way or specific ways for certain compilers)
e.g
if(!Logical)
printf("Not logical value at line number %d \n",LineNumber);
// How to get LineNumber without writing it by my hand?(dynamic compilation)
You could use a macro with the same behavior as printf(), except that it also includes debug information such as function name, class, and line number:
These macros should behave identically to printf(), while including java stacktrace-like information. Here's an example main:
Which results in the following output: