[comp.sys.hp] CC, emacs, and the three bears

colin@tcs.com (Colin Kendall) (06/07/91)

I am using /usr/bin/CC on an HP9000S300. I believe that
is the HP-UX C++ translator.

I am also using GNU Emacs version 18.55.something.

I have recently discovered a highly useful feature in emacs whereby
the user can simply say 'compile' and all the make output is
spewed into a buffer. While the make is continuing, the user
can use a command to move to the next error in the buffer and
simultaneously pull up the relevant source file, positioned to
the offending line, in another buffer. 

However, emacs can only recognize errors when they are in a
certain format. Consider the following partial output from
a make:


compiling ../getmaps.c
	rm -f getmaps.o
	/usr/bin/CC -c  -Aa -g -I.. -I$WORKROOT/include -I$PROJROOT/include -I$TOOLROOT/include -I/usr/include/CC -I$PROJROOT/include/Std -DANSI -DSYSV -D__cplusplus  ../getmaps.c
getmaps.c: 18: warning- extra characters on #endif.
cfbasics.h: 37: warning- Redefinition of macro ANSI.
getmaps.c: 610: warning- extra characters on #endif.
CC: "../getmaps.c", line 116: warning 117:  id not used

Emacs recognized the first three warnings (from cpp), but not the
fourth (from cfront).

I want it to recognize all the errors and warnings.

One partial solution is to wait until the make is finished, then
run some script on the error buffer to convert all the errors to
a recognizable format, then start going through the errors. But I
would prefer this to be done automatically, and I would rather not
wait until the make is finished.

So if anyone has some better idea, let's have it...
--


colin 

jimp@cognos.UUCP (Jim Patterson) (06/10/91)

In article <2308@godzilla.tcs.com> colin@tcs.com (Colin Kendall) writes:
>I am using /usr/bin/CC on an HP9000S300. I believe that
>is the HP-UX C++ translator.

>I am also using GNU Emacs version 18.55.something.

>However, emacs can only recognize errors when they are in a
>certain format. Consider the following partial output from
>a make:

>getmaps.c: 18: warning- extra characters on #endif.
>cfbasics.h: 37: warning- Redefinition of macro ANSI.
>getmaps.c: 610: warning- extra characters on #endif.
>CC: "../getmaps.c", line 116: warning 117:  id not used

>Emacs recognized the first three warnings (from cpp), but not the
>fourth (from cfront).

>I want it to recognize all the errors and warnings.


Emacs allows the definition of an error message to be specified by
means of a variable called compilation-error-regexp . It's defined
in the file lisp/compile.el (which is under /usr/local/emacs in a
"standard" installation of emacs). You can set it in your .emacs file
or in the default.el file for your site via setq, e.g.

(setq compilation-error-regexp
  "\\([^ :\n]+\\(: *\\|, line \\|(\\)[0-9]+\\)\\|\\([0-9]+ *of *[^ \n]+\\)")

(This version is the one from compile.el that you need to change).

If things are really messed up, you may need to modify compile.el as well.
-- 
Jim Patterson                              Cognos Incorporated
UUNET:uunet!cognos.uucp!jimp               P.O. BOX 9707    
BITNET:ccs.carleton.ca!cognos.uucp!jimp    3755 Riverside Drive
PHONE:(613)738-1440 x6112                  Ottawa, Ont  K1G 3Z4

evan@plxsun.uucp (Evan Bigall) (06/10/91)

In article <2308@godzilla.tcs.com> colin@tcs.com (Colin Kendall) writes:
>However, emacs can only recognize errors when they are in a certain format.

Hint: Get help on the variable compilation-error-regexp

/Evan
--
Evan Bigall, Plexus Software, Santa Clara CA (408)982-4840  
...!sun!plx!evan or evan%plx@sun.com
"I barely have the authority to speak for myself, certainly not anybody else"

dlw@odi.com (Dan Weinreb) (06/12/91)

In article <2308@godzilla.tcs.com> colin@tcs.com (Colin Kendall) writes:

   Emacs recognized the first three warnings (from cpp), but not the
   fourth (from cfront).

   I want it to recognize all the errors and warnings.

   So if anyone has some better idea, let's have it...

Just modify the function compilation-parse-errors in the file
compile.el in your GNU Emacs sources to know about this format.

In fact, you might only need to modify the regular expression
compilation-error-regexp.

bla@hpcupt1.cup.hp.com (Brad Ahlf) (06/13/91)

> I am using /usr/bin/CC on an HP9000S300. I believe that
> is the HP-UX C++ translator.

Correct.  Probably the older version A.02.00.  "what /usr/bin/CC"

> However, emacs can only recognize errors when they are in a
> certain format. Consider the following partial output from
> a make:
> CC: "../getmaps.c", line 116: warning 117:  id not used
> Emacs recognized the first three warnings (from cpp), but not the
> fourth (from C++).  I want it to recognize all the errors and warnings.

Due to a complaint from another customer (not sure if it was for emacs
or some other error message parsing program) we changed the error
message format for HP C++ in the newer 2.1 version so that it is easier
to find the error number and also easy to parse.  We now place the
error/warning number at the end of the line in parenthesis and leave the
line number as is.  See the following example message.  We plan to
maintain this format in the future (unless of course you have some other
very compelling reason for us to do otherwise).

CC: "errmsg.C", line 3: warning:  id not used (117)

If Emacs does not handle this either, it should not be too hard to
hack it to accept this new format (or the old format).  Emacs is
great that way, you can configure it to do just about anything.
Sorry, I do not use emacs in this way and do not have these hacks.

Brad Ahlf
bla@hplgsup1.cup.hp.com
#include <standard diclaimer about speaking for me and not for HP.  No
	  warranties expressed or implied.>

P.S. You might want to update to the latest HP C++ products.  2.1 translator
     has been shipping on S300/400 for 7.0 for several months.  2.1 native
     compiler will be shipping for S300/400 on 8.0 very soon.  S800 already
     has 2.1 native compiler for 7.0 and soon 8.0 and S700 8.05 compiler too.