From: Charles Krug Newsgroups: comp.os.msdos.djgpp Subject: Re: Works on WATCOM, doesn't work on DJGPP? Date: Mon, 30 Nov 1998 09:56:14 -0500 Organization: Pentek Corporation Lines: 42 Message-ID: <3662B20E.35394DA5@mail.pentek.com> References: NNTP-Posting-Host: mail.pentek.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [en] (WinNT; U) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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