[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: struct member initialization
From: |
Paul Pluzhnikov |
Subject: |
Re: struct member initialization |
Date: |
Wed, 03 Jan 2007 09:03:16 -0800 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
fernspaanakker@gmail.com writes:
> Sorry if my example code was incomplete.
Your sample is still non-compilable (you should strive to post
complete compilable test cases), but easily fixed with 2 typedefs.
The sample also compiles fine (gcc-3.4.6, 4.1.1) but with '-Wall'
gives a warning:
union.cc:21: warning: 'nString::<anonymous union>::strLen' will be
initialized after
union.cc:19: warning: 'ushort nString::<anonymous union>::<anonymous
struct>::localStrLen'
union.cc:28: warning: when initialized here
Note that this is completely different from the warning in your
original test case (at the start of this thread).
To eliminate the warning, swap the order of initialization:
inline
nString::nString() :
string(0),
localStrLen(0),
strLen(0)
{
}
Since you shouldn't actually care about either 'strLen' or
'localStrLen' when string == 0, both of these initializations appear
to be unneccessary.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.