Emacs regex to grok csc compilation errors

People have asked about this.  This is the regular expression I use to allow emacs' next-error function to handle csc error messages.  It is included in the emacs.el that I published previously.  Here it is excerpted for convenience.

;; to allow next-error to work with csc.exe:
(setq compilation-scroll-output t)
(setq-default compilation-error-regexp-alist
; (append
; Microsoft VJC:
;sample.java(6,1) : error J0020: Expected 'class' or 'interface'
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)[,]\\([0-9]+\\)): \\(error\\|warning\\) VJS[0-9]+:" 1 3 4)

;; dinoch - Wed, 04 Aug 2004 09:29
;; handle whitespace at beginning of line (for nant output)
;C# Compiler
;t.cs(6,18): error SC1006: Name of constructor must match name of class
("[ \t]*\\(\\([_a-zA-Z:\]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)[,]\\([0-9]+\\)): \\(error\\|warning\\) CS[0-9]+:" 1 3 4)

; Microsoft C/C++:
; keyboard.c(537) : warning C4005: 'min' : macro redefinition
; d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
;e:\projects\myce40\tok.h(85) : error C2236: unexpected 'class' '$S1'
;myc.cpp(14) : error C3149: 'class System::String' : illegal use of managed type 'String'; did you forget a '*'?
("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
\\(error\\|warning\\) C[0-9]+:" 1 3)
;; compilation-error-regexp-alist)


Comments (4)

  1. Alex Ott says:

    Had you send it to emacs-devel list? i think, that it will useful for other users of emacs 😉

  2. cheeso says:

    I didn’t know there was an emacs-devel list?  I’ll look for it.

  3. mschaef says:

    This is slick, but when I run msbuild on a solution, it recursively invokes build on each nested project with the recursive invocations in the directory containing the project file.  The net result is that the compiler output doesn’t contain the full path from the root of the solution, and next-error can’t find the files in the error message. Any thoughts on how to fix this?



  4. cheeso says:

    Hmmmmmmm, no I don’t.  Maybe there is an MSBuild option to NOT recurse, or to emit full paths, or something.  

Skip to main content