I have a code generator that is going to take some code written by the user and paste it into a larger generated file. I want the main compiler to provide good diagnostics in the presence of defects in the user code, but I also do not want the defects in the generated code to be incorrectly assigned to the source when they should not be.
I intend to issue the #line lineNum "sourceFile" directives at the beginning of each piece of user-written code. However, I cannot find the #line directive documentation that mentions the __LINE__ and __FILE__ "reset" __LINE__ back to the actual line in the generated file after I leave the code provided by the user. An ideal solution would be similar to the C # preprocessor directive #line default .
Do I just need to keep track of how many lines I wrote, and manually reset that I myself? Or is there a better way, some kind of reset directive or control value that I can pass to #line to erase the connection with the user code?
It seems that this was before , although there is no firm answer. To distinguish this from this, I will additionally ask if the lack of response has changed from C ++ 11.
source share