Mail Archives: djgpp/1998/11/30/10:06:31
Tal Lavi wrote:
> Hello,
>
> I'm using DJGPP 2.81, under DOS.
>
> I wanted to overload the = operator for my fixed point class, as seen in
> another class I download somewhere, that was meant for compiling under WATCOM.
>
> inline fixed &operator= (int a) {value = long(a)<<16;return *this;}
>
> As copied for the class's documentation:
>
> "In general, there are four of each operation , one each for fixed,
> int, float and double. Thankfully, Watcom will automatically cast
> any other ordinal types (short, long, char, unsigned int, etc.) to int."
>
> I was very disapointed to see that DJGPP does not have that quality!
> A simple test program compiles fine when using ints, but gives me errors for
> unknown combination of operands if I use unsigned longs.
>
> Does this is a true DJGPP flaw?
No. It's a quirk of Watcom's interpretation of the data promotion rules that the class
takes advantage of, but which is NOT guranteed across implementations.
Please consult Stroustroup's, "The C++ Programming Language," section C.6 on implicit
type conversions. If you don't have a copy, and you plan to work in C++, the go buy
one.
Charles.
--
Charles Krug, Jr.
Application Engineer
Pentek Corp
1 Park Way
Upper Saddle River, NJ 07458
- Raw text -