public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] g++-v3 and suspect C++ code in configtool
@ 2001-07-11 19:41 Richard Chan
  2001-07-12  3:33 ` Julian Smart
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Chan @ 2001-07-11 19:41 UTC (permalink / raw)
  To: ecos-discuss

(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>






















^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] g++-v3 and suspect C++ code in configtool
  2001-07-11 19:41 [ECOS] g++-v3 and suspect C++ code in configtool Richard Chan
@ 2001-07-12  3:33 ` Julian Smart
  0 siblings, 0 replies; 2+ messages in thread
From: Julian Smart @ 2001-07-12  3:33 UTC (permalink / raw)
  To: Richard Chan, ecos-discuss

At 10:47 AM 7/12/01 -0800, Richard Chan wrote:
>(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?)

It certainly should, thank you very much for pointing out these problems!

>[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?

Right, thanks. I'll add 'class' in the appropriate places.

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

OK -- I will wrap variables in wxString temporaries where the wxString + 
operator is the correct one to use.

Best regards,

Julian

--
Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK. CB1 
7EG Tel: +44 (1223) 271063

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-12  3:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-11 19:41 [ECOS] g++-v3 and suspect C++ code in configtool Richard Chan
2001-07-12  3:33 ` Julian Smart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).