Ryu
Ryu

Reputation: 8749

Eclipse CDT Custom Compiler Error Parsing Plugin

I'm using an uncommon C compiler with Eclipse CDT. I have a make file setup which is nice, but I'd like IDE integration with the error / warning output of my compiler.

Does anybody know what steps I can take to write a plugin for parsing / supporting my compilers output? I think it should be easy but there is a barrier of entry of figuring out where to start. Would be nice if Eclipse would let me do New -> Compiler Error Parser Plugin, or something like that.

Thanks

Upvotes: 3

Views: 7712

Answers (7)

Fredrik
Fredrik

Reputation: 10646

IBM has published a step-by-step guide to how you can write your own CDT parser, its available here

Relevant google search for future proofing should be: https://www.google.com/search?q=ibm+eclipse+write+cdt+parser&oq=ibm+eclipse+write+cdt+error+parser

Upvotes: 2

Leo
Leo

Reputation: 3126

In CDT 8 this functionality does not require a plugin. I have support for several compilers and build systems using simple regular expressions. See screenshot here. You can test the regexes directly in the console output before copying them to this dialog. If you need to move them between machines, the resulting parsers are stored in your workspace under .metadata/.plugins/org.eclipse.cdt.core

Upvotes: 0

Vanuan
Vanuan

Reputation: 33422

In Eclipse CDT 7.0.1 it's pretty simple. Just add a new error parser under Window -> Preferences -> C/C++ Build -> Settings and add regular expression with 3 groups: filename, linenumber and error description.

For example, for Visual Studio compiler regexp will be:

(.*?)\((\d*)\)\s:\s(.*error.*)

$1 - filename
$2 - line number
$3 - error description

Upvotes: 3

srkos
srkos

Reputation: 11

is this working ?

(.*)\((\d+)\)\s:\sError(.*)

file: $1 line: $2 desc: $3

. srkos

Upvotes: 1

Richard Miskin
Richard Miskin

Reputation: 1260

In CDT 7 there is going to be a regular expression error parser included which should make this sort of thing much simpler. There are some details on the faq.

CDT 7.0 won't be released until the end of June, but you could try milestone builds to see if it does what you want. These can be downloaded here. You'll need to have a matching milestone version of the eclipse platform too.

Upvotes: 1

crazyscot
crazyscot

Reputation: 11989

It's not quite that simple...

First of all make sure you have the Eclipse PDE (Plug-in Development Environment) and CDT SDK installed. If not then you'll need to tell Eclipse to download them (Help -> Install New Software).

Then, create a new Plug-In project. In its Extensions tab, add a new extension against point org.eclipse.cdt.core.ErrorParser. You will then have to write some java code to actually implement it. Fortunately the PDE makes the meta-work relatively straightforward; you put the name of your class in the appropriate box and click on the "class*" hyperlink and it will offer to create a skeleton class for you.

I suggest you grab the source code to the CDT and have a look at GCCErrorParser.java as an illustration of the sorts of things yours will have to do.

Finally, when you're ready to test it, set up a debug configuration of type Eclipse Application. (This will spawn a second instance of Eclipse; it has to use a different workbench.) Go into the properties of your C project, Settings panel, Error Parsers tab and switch on your shiny new error parser.

Upvotes: 3

Related Questions