Author Topic: Underlining Compile errors in code  (Read 6920 times)

Offline koonschi

  • Multiple posting newcomer
  • *
  • Posts: 27
    • My personal project
Underlining Compile errors in code
« on: September 19, 2013, 04:51:12 pm »

I was thinking of writing a plugin for codeblocks for underlining compile errors and warnings in the code.
A lot of IDEs have this feature and I find it extremely useful when I can see the errors without hitting F9 to recompile the code, especially when working on bigger projects where compile times are generally higher.

To realize this, I was thinking of creating a plugin that basically runs the compiler in the background for the currently opened file, build target, and project. This would of course take into account the project settings specified by that build target/project.
After the compiler finished, its output is parsed, and the lines specified in the output are underlined.
When you hover your mouse over the underlined line you get a tooltip telling the exact error.

I think that this should not be too hard to achieve, as codeblocks can already parse compiler output, and it can underline things in the editor.

Now, there is a general problem with this approach: Compiling takes time. So the compiler would only be run for the currently edited file (the one in the editor that has the focus).
And it would be run possibly whenever the file is saved or opened (I'm open for proposals).
Of course, underlining specific errors in one line would not be possible with all compilers. Imagine 2 statements in 1 line, with some compilers it would be hard to find out which statement caused the error. For now I only know 2 compilers that are specific enough for such things, gcc 4.8+ and clang.
So I'd say I underline the whole line (except for the starting spaces).

The big (rather obvious) downside of such a plugin would be its performance consummation, as a compiler thread (process?) would be running almost non-stop in the background. Especially if you're a programmer who hits CTRL + S often.

So, would writing such a plugin be realistic? I'm asking because I've never before seen something similar in the forums, and maybe I'm overlooking something?
"As a general rule, the compiler is smarter than you, and working in your best interest. Do not question it." - Terry Mahaffey

#define TRUE FALSE // happy debugging suckers

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5377
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Underlining Compile errors in code
« Reply #1 on: September 19, 2013, 05:11:17 pm »
There is already such plugin by morten, I forgot the name. Maybe compile on save plugin. You can search the forum.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]