This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++-v3 and suspect C++ code in configtool



(I know 2.95.2 is the recommended version :-) but
let's live on the edge here...after all
if the C++ code is suspect but was passed by 2.95.2 shouldn't
it be cleaned up?)

g++ v3 does not like some of the C++ constructs in
configtool; are the following due to dubious C++ code or
a bad compiler? (BTW g++-v3 builds wxwindows 2.3.1 snapshot 
and the demo programs run)


[Problem 1]
friend X or friend class X declarations

v3 is now fussy about "class"  key-name - is this the behaviour expected
by the standard?

Compiling aboutdlg.cpp

In file included from /d1/cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/ecpch.h:64,
                 from /d1/cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/aboutdlg.cpp:50:
/d1/cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/configtool.h:105: friend
   declaration requires class-key, i.e. `friend class ecMainFrame'
make: *** [/d2/home/cshihpin/src/ecos-build/ct-build-release/aboutdlg.o] Error 1

Same problem in mainwin.h

[Problem 2] 
operator overloading of + in   w+e where w is a wxString and e is an ecFileName
completely blows g++.


Compiling configtool.cpp
/d1/cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/configtool.cpp: In
   member function `bool ecApp::PrepareEnvironment(bool, wxString*)':
/d1/cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/configtool.cpp:927: choosing
   `wxString operator+(const wxString&, const wxString&)' over `ecFileName
   operator+(const ecFileName&, const ecFileName&)'

...many similar error messages deleted...

/d1/cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/configtool.cpp:945:
   because worst conversion for the former is better than worst conversion for
   the latter
make: *** [/d2/home/cshihpin/src/ecos-build/ct-build-release/configtool.o] Error 1

This is the offending line
 (* cmdLine) += wxString(wxT("export PATH=")) + strBinDir + wxT(":$PATH; ");


Here is a minimal C++ file that can trigger this overloading confusion.
Seems that it can't decide between

wxString operator+(const wxString&, const wxString&)
ecFileName operator+(const ecFileName&, const ecFileName&)

#include <wx/string.h>
#include <filename.h>

main()
{
	wxString w;
	ecFileName e;

	w + e;
}

So if you have ClassA and ClassB derived from ClassA;
ClassA has operator+(const ClassA&, const ClassA&), 
ClassB also has operator+(const ClassB&, const ClassB&)  
ClassB has a constructor ClassB(ClassA)

Then if x is a ClassA and y is a ClassB what should be
called in the case of 
	x + y
i.e. operator+ from ClassA or from ClassB?

That's all for now.

Thanks
Richard Chan <cshihpin@dso.org.sg>























Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]