Topic: Warnings
Author: fgothamNO@SPAM.com (Frederick Gotham)
Date: Thu, 13 Jul 2006 14:31:47 GMT Raw View
Keith Thompson posted:
> What warning does the cast inhibit? I don't get a warning with or
> without the cast. (I do get warnings on the literals, depending on
> command-line options.) The cast specifies an explicit conversion;
> without it, there's still an implicit conversion. There's no obvious
> reason why adding or removing the cast should affect whether there's a
> warning.
Most -- if not all -- C++ compilers warn about implicit conversions from wider
types to narrower types, e.g.:
(Let's pretend I initialise them first:
float a; double b; a = b;
int a; long b; a = b;
char a; short b; a = b;
Warnings can be a right pain in the neck when it comes to C++ programming,
which is why I recently started a thread entitled "Deliberately Supress
Warnings" on this newsgroup.
Another common warning is arithmetic between signed and unsigned types.
--
Frederick Gotham
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]