Re: Looking for a warning when casting 'const char *' to bool.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 22, 2008 at 7:00 AM, Eljay Love-Jensen <eljay@xxxxxxxxx> wrote:
> Since there is only one selectable routine, there is no ambiguity.  Hence,
> no warning (or error).
>
> One workaround I've used is to make my own Bool class that isn't "bool
> promiscuous", but that does not appear to be viable / desirable in the
> example code you provided.

Although that work work, I'm not a big fan of redefining base types like that.

Assuming you haven't already have you looked into using std::string
It would provide the functionality and type-safety you want.

It also seems like you have some code quality issues if you have to
generate warnings for incorrect function calls.  Either you should be
able to rely on passing valid parameters to some extent or you need to
fix the parameter types.  Is there a big reason to make the parameter
char* instead of const char*?  Any string literal will be const!

corey

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux