Re: char y = 469;

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

 



Hi stf_polska,

To get a warning or error for that kind of construct, you need to use a
language like Ada where that would be a warning/error.

In C and C++, it isn't a warning because it is expected and standard
practice.

So for C and C++, the way to turn that into a RUNTIME warning is to write an
IntToChar routine:

int x = 469;
char y = IntToChar(x);

Where IntToChar can log or throw or terminate, depending on your preference.

For C++, there is a Boost numeric_cast, which has this kind of capability.
Boost library is located at www.boost.org and is free, and darn impressive.

HTH,
--Eljay


[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