This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Is it a valid C++ structure initialization?
- From: "Sergey Okhapkin" <sos at prospect dot com dot ru>
- To: <cygwin-developers at cygwin dot com>
- Date: Mon, 25 Nov 2002 18:50:10 -0500
- Subject: Is it a valid C++ structure initialization?
Here is a test program (wich seems to me incorrect):
struct asd {
int a;
char b;
};
void f(int i, char c)
{
struct asd qwe = {
a: i,
b: c
};
}
The program compiles fine with gcc-3.2. Gcc 3.3 current snapshot reports:
test.cc: In function `void f(int, char)':
test.cc:11: error: too many initializers for `asd'
Solaris compiler complains:
$ CC -c test.cc
"test.cc", line 9: Error: a is not defined.
"test.cc", line 9: Error: Unexpected ":" found.
2 Error(s) detected.
The reason I'm asking about is that such kind of structure initialization is
used in cygwin sources (fhandler_socket::readv/writv, syscalls.cc
readv/writv, a whole bunch in wincap.cc). gcc 3.3 fails to build
cygwin1.dll. And I agree with the compiler. Removing "fieldname:" makes all
compilers happy.
Sergey Okhapkin
Somerset, NJ