Closed GoogleCodeExporter closed 9 years ago
Here is a patch which fixes this issue, and also issue 281, and many other
unreported problems where Arduino fails to report the correct line number, file
and/or highlight the error in the editor!
Original comment by paul.sto...@gmail.com
on 6 May 2012 at 7:26
Attachments:
Here's some explanation about what my patch does....
First, #line directives are added to the preprocessed sketch. These let the
compiler report the correct file and accurate line number, regardless of how
many tabs are open.
When errors are reported, the complex code which tried to match up offsets is
replaced by a very simple search to match the file with its tab in the editor.
Because the compiler gives dependable results, pde, ino, cpp, h, and c files
are all handled the same way.
A flag is added, to distinguish between compiling the user sketch versus
lirbaries and the core. The attempt to select the errorenous line (and correct
tab) in the editor is skipped if the file is not part of the user's sketch.
This avoids a bug where errors are reported incorrectly if the user's sketch
contains a .cpp file which has the same filename as any file in any library.
An off-by-one error is fixed in code which attempts to show the error using
only the "pretty name" (without trailing .ino or .pde). The editor's
zero-based index is now properly put back to the one-based line number
counting, so the error reported in the console has a line number which matches
the line automatically selected in the editor.
The "pretty name" reporting is now applied to both .ino and .pde extensions.
This patch does NOT remove lots of code which tracked various offsets created
during preprocessing. It also does not alter the API between the Compiler and
Sketch objects, which no longer needs to be able to modify what information the
error will print. I tried to keep the scope of changes limited to only fixing
the bugs which prevent proper error messages and properly selecting the
offending line in the editor.
Original comment by paul.sto...@gmail.com
on 6 May 2012 at 10:30
Also, because any .cpp, .c and .h files in the user's sketch are handled the
same way, if there is a compile error in any of those files, it will be
correctly selected, just like the .ino files are.
Original comment by paul.sto...@gmail.com
on 6 May 2012 at 10:32
This patch works beautifully! This will make debugging much easier. ADMINS,
please add this patch to the next Arduino release!
Thanks for your work, Paul!
Brett
Original comment by bre...@teleport.com
on 6 May 2012 at 11:26
Looks good (although I didn't examine it in detail). This may be too late for
1.0.1 but I'll definitely get it in for the next version.
Original comment by dmel...@gmail.com
on 7 May 2012 at 3:56
Yeah, if you're building the final 1.0.1 now, it definitely makes sense to wait
for 1.0.2.
But next time you have Arduino open and there's any error, please glance at the
line number on error message in the console and the editor's line number (in
the blue region between the code editor and console). They don't match. We've
all grown very accustomed to Arduino's many bugs.
The more serious bugs, which make Arduino difficult to use, are only
encountered with a multi-tab sketch. Most people use only a single tab.
Original comment by paul.sto...@gmail.com
on 7 May 2012 at 6:08
https://github.com/arduino/Arduino/commit/77ed2f4d62d51ca9d79f3353936e9d359d886c
cb
Thanks!
Original comment by dmel...@gmail.com
on 27 May 2012 at 4:34
I'm also having the problem that the IDE editor is not stopping at the correct
line number when errors are flagged. How do I obtain this patch, and what is
the procedure for applying it?
Thanks,
Original comment by craighal...@gmail.com
on 13 Aug 2012 at 12:07
The easy answer is just wait for 1.0.2.
But you can get the latest source code and compile it. You'll need the Java
JDK, Ant, and if using Windows, lots of cygwin stuff. Instructions are here:
http://code.google.com/p/arduino/wiki/BuildingArduino
Original comment by paul.sto...@gmail.com
on 13 Aug 2012 at 4:03
I'm very sorry, there was a bug in my patch, where it didn't properly handle
comments and white space that offsets the insertion point.
This tiny patch fixes the problem.
Original comment by paul.sto...@gmail.com
on 28 Sep 2012 at 12:26
Attachments:
Original issue reported on code.google.com by
bre...@teleport.com
on 6 May 2012 at 5:14