returning lvalue in C vs C++
- From: Ben C <spamspam@xxxxxxxxx>
- Date: 29 Mar 2006 22:12:56 GMT
Can anyone explain this:
struct thing
{
int x;
};
struct thing f(void)
{
struct thing ret = {100};
return ret;
}
int g(void)
{
return 10;
}
int main(void)
{
#if 0
g() = 4; /* "invalid lvalue" in C and C++ */
#endif
f().x = 200; /* "invalid lvalue" in C, but not in C++ apparently */
return 0;
}
$ gcc -x c++ main.c
no problems in C++, but
$ gcc -x c main.c
main.c: In function â??mainâ??:
main.c:17: error: invalid lvalue
I'm using gcc version 4.0.2 20050901.
.
- Follow-Ups:
- Re: returning lvalue in C vs C++
- From: Alf P. Steinbach
- Re: returning lvalue in C vs C++
- From: Phlip
- Re: returning lvalue in C vs C++
- Prev by Date: Re: Yacc = Bison???
- Next by Date: Re: returning lvalue in C vs C++
- Previous by thread: Yacc = Bison???
- Next by thread: Re: returning lvalue in C vs C++
- Index(es):
Relevant Pages
|