[openbeos] Re: C++ Compatibility

  • From: "Scott MacMaster" <scottmacmaster@xxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sun, 17 Mar 2002 20:52:18 PST (-0800)

> Are you referring to the the STL that is distributed with BeOS R5, or 
> to
> the Be headers like Application.h, Window.h,... ?

I refering mainly to the files under headers/cpp/ and headers/posix/.  
I don't think I've had an issue with any other header files.

> Are you sure? Can you post examples?

As for an example:
///////////////////////////
#include <string>

int main()
{
        return 0;
}
///////////////////////////

Now, go into the BeIDE project settings and under Language/C++ 
Warnings.  Their I turned on these settings:
 -Issue all warning demanded by strict ANSI C/C++
 -Warn when one local variable shadows another
 -Warn about overloaded virtual functions names
 -Warn if a c-style cast is used in a program
 -Warn about violations of "Effective C++" style rules

Now compile.  You'll get 69 warnings.  In my previous e-mail I 
indicated I got a lot more.  This was, of course, not from compling 
this example.  That number was from a much larger program. I'm working 
on.

Recently I've been editing the header files on my system and adding in 
c++ type casting operators.  Once I finish I'll be able to use the 
option, "warn if a c-style cast is used in a program."  If I recompile 
the same example above but when my modified header files I get 37 
warnings.

> But what is so bad about a C style cast, if it is used properly?
> Whenever a dymic_cast<> is necessary, I would use it.

The problem is that you can accidentally use it improperly.  It's 
possible to misuse the c++ style cast but for the most part it's a lot 
harder to accidently make a mistake if you you the c++ style cast.  
Basically, this is because you're telling the compiler what kind of 
casting you're doing and it makes sure that you did do that.

> >     -Not using the initializer list in the constructors of classes
> Sometimes not easily possible, but in the simple case, it should be 
> used, agreed.

Sometimes my initializer list gets kinda' long but I put it in all my 
classes.


Thanks,
Scott MacMaster
www.CodeLiege.com


Other related posts: