Closed ismagilli closed 6 months ago
For code
void f(void) { // line 1
int x = 10 // line 2
int y = 20; // line 3
} // line 4
the compiler says that an error on line 3 because after 10
it try to read something different from int
(operator / ,
/ ;
), but it read int
.
Compiler output:
<source>: In function 'f':
<source>:3:5: error: expected ',' or ';' before 'int'
3 | int y = 20;
| ^~~
Compiler returned: 1
In this case, the real error in line 2. On stream you have situation like following:
genf("int x = 10"); // line N
genf("int y = 20;"); // line N+1
The compiler says that the error in the code is generated by line N+1, but you know that error in the сode is generated by line N. This led to the erroneous assumption that it is necessary to subtract one.
Yeah, I think there was something wrong with my Emacs at the time of writing this. Its go to line command had off by one moment for whatever reason. Now it's fine. Thanks!
The correct line number of the source file for the generated code.
See for example following code and it's output: