Re: [Audacity-devel] Warnings from recent check-ins
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: Dawson W. <wri...@gm...> - 2008-10-14 05:38:43
|
Richard Ash (audacity-help) wrote: > > This one isn't at all new, but I'm quite confused what the cause might be. > Any ideas? > The C++ standard says that the order of initialization here follows the order of how the member variables are declared and not the order of the initialization list. When it is different, the warning is given. > FileIO.h: In constructor ‘FileIO::FileIO(wxString, FileIO::FileIOMode)’: > FileIO.h:50: warning: ‘FileIO::mOpen’ will be initialized after > FileIO.h:44: warning: ‘wxString FileIO::mName’ > FileIO.cpp:19: warning: when initialized here > > Or more accurately, why should I care about initialisation order in a > constructor? > > Richard > In this case you are right. It doesn't matter one bit. The only case it would is if you had the initialization of one depend on the value before it, then the order did matter. For instance if in this case and ignoring the types for the time being, mName was initialized in some form, mName(something + mOpen - or_another), even though mOpen was listed before mName in the initialization list, it would be undefined, because of the order it was defined in the class. It is perfectly legal to initialize this way in C++ just as long as it is initialized first. So either switching the order in one of the places would do it. In this case, I thought since the order of the variables should match that of the constructor's parameters, it should be changed in the header file to match it. Anyway, changing this made FileIO warning free (at least for me and for now) ;-). Dawson -- View this message in context: http://n2.nabble.com/Warnings-from-recent-check-ins-tp259354p1331664.html Sent from the audacity-devel mailing list archive at Nabble.com. |