[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

learning compiler error messages



One of the skills involved in using compiler is learning what
the messages mean.  After 10 years of using the various UNIX
C compilers the messages make all make sense, even though they
might seem a little obscure to the novice.

C++ is a different story.  I'm slowly learning what the various
spurious warnings mean, "virtual bar hides bar in superclass" messages
refer either to type mismatches (a reasonable message) or to multiple
messages in a superclass with the same name as in the subclass, but
with the sub class having some missing messages, the same message is
emitted even when the superclass methods are pure virtual, this is an
error both in your program and in the compiler as it simply emits a confusing
warning.

Now for the real content of this message.  As I was compiling our FM event code
I got the message 

"./eventqx.hxx", line 191: error:  class inputevent defined twice

Line 191 was the 
} 
at the end of a class definition so no help there.

As inputevent didn't appear in any of our code and didn't conform to our 
naming conventions anyway I assumed it was in an include file.  
Our code doesn't use many external includes in this case the only one
was:

#include <xview/win_input.h>

which contained the fragment:

typedef struct  inputevent {
        short   ie_code;                /* input code */
        short   ie_flags;
        short   ie_shiftmask;           /* input code shift state */
        short   ie_locx, ie_locy;       /* locator (usually a mouse) position */
        struct  timeval ie_time;        /* time of event */
        short   action;                 /* keymapped version of ie_code */
        Xv_object       ie_win; /* window the event is directed to */
} Event;

and didn't contain inputevent any where else.  In fact inputevnt wasn't
in the other include files that our code used.  Quite a Puzzle.

The answer wasn't eaisly accesable to my feeble brain at 3am untill
I tried to get to sleep.  The answer is "Global Name Space Considered Harmfull"
i.e. "Event".

We have been somewhat careful in our code to avoid terms like "Object" & 
"Window" but we used "Event", well we won't any more.

I am still amazed at the error message

"./eventqx.hxx", line 191: error:  class inputevent defined twice

and its amazing clarity of misdirection.  I'm not mad at the
compiler writer particularly, and when I (or you) see this again
we won't be too confused, but it is sometimes breathtaking to realize
how much crappy trivia one gets to know in this business.