I was wondering if anyone could help me figure out why the compilation-error-regexp for IAR ( compilation-error-regexp-alist-alist, in compile.el ) does not work?

The regexp is:

 1 2 nil (3))

An IAR EWARM (7.80.4) error/warning message has the following format:

c:\someFolder\someFile.cpp(18) : Error[Pe018]: expected a ")"
c:\someFolder\someFile.cpp(26) : Warning[Pe012]: parsing restarts here after previous syntax error

I have no experience with Emacs regular expressions, so any help would be greatly appreciated.

Note that the error/warning features of compile.el work for python, so it does not seem to be a configuration issue.

Emacs version: emacs-25.1.1 (x86_64-w64-mingw32)

Edit: Thanks! That was very helpful. Using M-x re-builder I was able to use the pattern you provided to make the following expression :


It detects the filename and line number. I am however still not able to make it work in compilation mode, as I don't quite understand the remaining arguments of compilation-error-regexp-alist-alist. The documentation states:

"Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK HIGHLIGHT...]). If REGEXP matches, the FILE'th subexpression gives the file name, and the LINE'th subexpression gives the line number. The COLUMN'th subexpression gives the column number on that line."

As far as I can tell the complete expression should be something like: (iarbuild "\\(^..*\\.cpp\\|^..*\\.c\\|^..*\\.hpp\\|^..*\\.h\\)(\\([0-9]+\\))\\s-+:\\s-+\\(?:Error\\|Warnin\\(g\\)\\)\\[[Pe0-9]+\\]:.*" 1 2 nil)

But I can't get it to work. Any tips?

  • Don't forget Remark, which is a kind of message you get when you have enabled remarks in the compiler settings. Mar 5, 2017 at 19:23
  • @Lindydancer: Would Remark be proper value for Info that I was guessing at in my answer? I did wonder about simply making that group \\(.+\\) to mean "anything other than an Error or a Warning"; but if all lines will specify either Error, Warning, or Remark then the regexp may as well use it explicitly.
    – phils
    Mar 6, 2017 at 22:10
  • If I remember correctly, the levels are Fatal Error (e.g. when a header file is missing), Error, Warning, and Remark. I would strongly recommend a regexp that match these explicitly, to avoid false positives. Mar 7, 2017 at 19:58

1 Answer 1


I suggest you use M-x re-builder on the compilation errors buffer (or just a buffer containing the text you want to match).

If you start with this edited pattern:


You'll probably be able to figure it out from there?

I imagine something like the following might do the trick?

  1 2 (3 . 4))

I'm guessing at the "Info" part, just because the (WARNING . INFO) syntax looks like it requires some kind of Info group. It's possible that just (WARNING) would suffice, but I've not checked.

Groups \\( ... \\) are numbered from 1, but note that instances of \\(?: ... \\) are non-capturing groups, which aren't numbered.

Hence 1 is the FILE group; 2 is the LINE number group; and (3 . 4) is (WARNING . INFO)

Here's an rx equivalent for that regexp:

(rx (group bol (one-or-more not-newline) "." (or "cpp" "c" "hpp" "h"))
    "(" (group (one-or-more digit)) ")"
    (one-or-more whitespace) ":" (one-or-more whitespace)
    (or "Error" (group "Warning") (group "Info"))
    (zero-or-more not-newline))

Note also Lindydancer's comments -- you may wish to introduce "Remark" into this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.