* funny syntactical error message
@ 2000-03-08 3:35 Ulrich Lauther
2000-03-08 13:12 ` Martin v. Loewis
0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Lauther @ 2000-03-08 3:35 UTC (permalink / raw)
To: gcc
Compilation of
class foo {
public:
int fudge[40];
int bar [40];
inline int access(int i) {
return bar(i);
}
};
gives
test.C:7: `(this + 160)' cannot be used as a function
if fudge is ommitted, you get
test.C:7: `this' cannot be used as a function
Why not "bar cannot be used as a function?"
(this is 2.95.1)
--
-lauther
----------------------------------------------------------------------------
Ulrich Lauther ph: +49 89 636 48834 fx: ... 636 42284
Siemens ZT SE 4 Internet: Ulrich.Lauther@mchp.siemens.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: funny syntactical error message
2000-03-08 3:35 funny syntactical error message Ulrich Lauther
@ 2000-03-08 13:12 ` Martin v. Loewis
0 siblings, 0 replies; 4+ messages in thread
From: Martin v. Loewis @ 2000-03-08 13:12 UTC (permalink / raw)
To: Ulrich.Lauther; +Cc: gcc
> Why not "bar cannot be used as a function?"
Thanks for your bug report. I've put it into GNATS.
Regards,
Martin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: funny syntactical error message
2000-03-08 10:24 rlau
@ 2000-03-08 10:41 ` Mo McKinlay
0 siblings, 0 replies; 4+ messages in thread
From: Mo McKinlay @ 2000-03-08 10:41 UTC (permalink / raw)
To: rlau; +Cc: gcc, Ulrich.Lauther
# 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: funny syntactical error message
@ 2000-03-08 10:24 rlau
2000-03-08 10:41 ` Mo McKinlay
0 siblings, 1 reply; 4+ messages in thread
From: rlau @ 2000-03-08 10:24 UTC (permalink / raw)
To: gcc, Ulrich.Lauther
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];
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Compilation of
class foo {
public:
int fudge[40];
int bar [40];
inline int access(int i) {
return bar(i);
}
};
gives
test.C:7: `(this + 160)' cannot be used as a function
if fudge is ommitted, you get
test.C:7: `this' cannot be used as a function
Why not "bar cannot be used as a function?"
(this is 2.95.1)
--
-lauther
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2000-03-08 13:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-08 3:35 funny syntactical error message Ulrich Lauther
2000-03-08 13:12 ` Martin v. Loewis
2000-03-08 10:24 rlau
2000-03-08 10:41 ` Mo McKinlay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).