funny syntactical error message

Mo McKinlay mmckinlay@labs.interopen.org
Wed Mar 8 10:41:00 GMT 2000


# In the inline function access, are you trying to return a specific element of
# bar[] ?  If so, your syntax might be the source of the problem.
# Try
# return bar[i];

This is certainly a way to prevent the error message from appearing -
however, IMHO, the error that g++ produces in this case is misleading. It
may be technically correct, but displaying an offset to this instead of a
member name isn't exactly a user-friendly tactic to use when issuing
errors.

[I think, incidentally, that this was the intent of the original message]

Consider:

foo.c:7: 'this + 40' cannot be used as a function

and:

foo.c:7: 'bar' cannot be used as a function

In the example given in previous messages, the source of the error is
clear in both cases. However, consider a statement which accesses several
members of a class. If the offset to 'this' is given, the programmer must
scan the line for each member and check if the synatax is correct (I
believe that this error would in most cases be caused by a typographical
error). However, if the member name is given, the programmer can easily
pinpoint the source of the error.

-- 
Mo McKinlay                                T: +44 (0) 709 22 55 05  x1
Chief Software Architect                   F: +44 (0) 709 22 55 05  x3
inter/open                                 E: mmckinlay@labs.interopen.org
A division of Bekon Marketing Limited      W: http://www.interopen.org



More information about the Gcc mailing list