Salem, this is the solution I currently use before the C preprocessor. It has the weakness that if there is a #if/#endif enclosing the lines you added, then the scheme fails.
If I were to work using your suggestion: after the C preprocessor, then the #line directive won't work I think. I looked...
Yes cpjust, this is the solution I gave. After every #else or #endif you recalculate the line number and issue a #line.
But that makes you program more complex. Which is unfortunate. The C standard should have specified that #line is not subject to #if conditions.
Yes, one option is to process the file after the C preprocessor. But this option has its own issues.
For example, if I insert new lines in the file, how do I inform the compiler of the new line numbering? Is there a standard method or is it compiler dependent?
Replacing #if 0 with #if 1: of course then it works.
My point is that line numbering should be independent of other compiler directives. Line numbering should not change if I use #if 0 or #if 1. The line number in the file does not change!!!
We could distinguish between two things:
- Regular...
This is to propose an improvement to the #line directive of the C preprocessor, or to ask for a workaround.
Currently, it seems that the #line directive is "ignored" if it lies between a #if and a #endif directives !
I believe that in most practical cases, this behavior is undesired.
Example...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.