 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Glen Able Guest
|
Posted: Fri Jan 28, 2005 2:35 pm Post subject: Reference + initialiser oddity. |
|
|
Kindly consider:
struct MyStruct
{
Foo* foo;
Bar& bar;
};
void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}
This works fine on a gcc port. However vc6/.net give this cryptic error:
'm' : non-aggregates cannot be initialized with initializer list.
It appears that it's the Bar& that's the problem, not the Foo*. Anyone able
to shed light on this for me?
thanks,
G.A.
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Fri Jan 28, 2005 2:45 pm Post subject: Re: Reference + initialiser oddity. |
|
|
Glen Able wrote:
| Quote: | Kindly consider:
struct MyStruct
{
Foo* foo;
Bar& bar;
};
void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}
This works fine on a gcc port. However vc6/.net give this cryptic error:
'm' : non-aggregates cannot be initialized with initializer list.
It appears that it's the Bar& that's the problem, not the Foo*. Anyone able
to shed light on this for me?
|
VC++ has problems with brace-enclosed initialisers for aggregates.
The behaviour is somewhat fixed in the version 7.1 (I checked).
V
|
|
| Back to top |
|
 |
Glen Able Guest
|
Posted: Fri Jan 28, 2005 3:36 pm Post subject: Re: Reference + initialiser oddity. |
|
|
"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> wrote
| Quote: | Glen Able wrote:
Kindly consider:
struct MyStruct
{
Foo* foo;
Bar& bar;
};
void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}
This works fine on a gcc port. However vc6/.net give this cryptic
error:
'm' : non-aggregates cannot be initialized with initializer list.
It appears that it's the Bar& that's the problem, not the Foo*. Anyone
able
to shed light on this for me?
VC++ has problems with brace-enclosed initialisers for aggregates.
The behaviour is somewhat fixed in the version 7.1 (I checked).
|
Right, so my code's all good and legal - hurrah!
thanks,
G.A.
|
|
| Back to top |
|
 |
Ioannis Vranos Guest
|
Posted: Sat Jan 29, 2005 1:21 am Post subject: Re: Reference + initialiser oddity. |
|
|
Glen Able wrote:
| Quote: | struct MyStruct
{
Foo* foo;
Bar& bar;
};
void Blah(Foo* foo, Bar& bar)
{
// create+initialise struct
MyStruct m = {foo, bar};
}
This works fine on a gcc port. However vc6/.net give this cryptic error:
'm' : non-aggregates cannot be initialized with initializer list.
It appears that it's the Bar& that's the problem, not the Foo*. Anyone able
to shed light on this for me?
|
Your code compiles with VC++ 7.1. Provided that I provide a definition
for both Foo and Bar.
--
Ioannis Vranos
http://www23.brinkster.com/noicys
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|