Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / August 2004



Tip: Looking for answers? Try searching our database.

A warning from MS VC7 I'd like to see CodeWarrior adopt - partly :-)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Conrad Weyns - 27 Aug 2004 17:28 GMT
// A classic test class:
class A
{
  public:
  A(char const*);
};

// A class with a dodgy interface:
class B
{
  public:
  void f(A const&)
  {
  }
  void f(bool)
  {
  }
};

void test()
{
  B b;
  b.f("");
}

b.f("") will call B::f(bool).
Note that declaring A(char const*) explicit makes no difference. Evidently,
the compiler chooses the build in convertion first anyway.

MS VC7 will output a warning:
  warning C4800: 'char *' : forcing value to bool 'true' or 'false'
(performance warning)

My colleges and I mostly turn a blind eye as soon as we see "(performance
warning)". In this particular case, I'd rather get a more meaningfull
warning e.g: "Are you sure you want us to do this?". "us" because I reckon
there has been more than 1 programmer coding the compiler...
I realize that most of the problem lies with the bool parameter since just
about anything on the face of this earth can be converted to a bool. The
example above is minimalistic. In our real code, we have bool IN-params all
over the place and many have default values which makes it all the worse.

So, just a wish!
Cheers,
Conrad Weyns
MW Ron - 27 Aug 2004 18:15 GMT
I'll submit this as a feature request,

Thanks for pointing it out.

>// A classic test class:
>class A
[quoted text clipped - 41 lines]
>Cheers,
>Conrad Weyns

Signature

Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
       --   http://www.metrowerks.com/community  --

Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.