Peter Gerwinski wrote:
function CompNum(var e1, e2: TestType):Integer; Var r : Real; begin r := e1 - e2; CompNum := Round(r); end;
Consider this with "TestType = Byte", then in `CompNum' we are subtracting two `Byte' variables from each other. GPC chooses the result type to be `Byte' again, so the result is never negative.
When I convert them to `Integer' by writing
r:= Integer ( e1 ) - Integer ( e2 );
it works. (First it did not work because of a bug in conversions among integer types, but I could fix this.;-)
However, is this the correct behaviour?
I think it is because...
Or should the result type of a subtraction be the "nearest" signed integer type - `ShortInt' in this example? Then, what to do when subtracting two `LongestCard's, especially in cases like "$FFFFFFFFFFFFFFFF - 2" where the result does not fit in `LongestInt'?
That's the problem. Also, this problem is basically the same as a multiplication of two Integers resulting in a LongInt. GPC (and BP) do not do any automatic conversion there, either.
IOW, the programmer is responsible for chosing the right types and converting when necessary. The best the compiler can do (and will do hopefully soon) is range checking.
-- Frank Heckenbach, Erlangen, Germany heckenb@mi.uni-erlangen.de http://home.pages.de/~fjf/links.htm
Hi,
Is there an easy way to stop GPC's runtime system from being built ? I ask because I have had some trouble with stopping it being built in a canadian cross compile :-) There probably is an easy way, but I had to hack several bits out of p/Make-lang.in and Makefile.in, which whilst not difficult was not as easy as it possibly could be ...
Thanks in advance for any help,
Regards,
Michael Meeks.
On Sun, 14 Sep 1997, Michael Meeks wrote:
Hi,
Is there an easy way to stop GPC's runtime system from being built ? I ask because I have had some trouble with stopping it being built in a canadian cross compile :-) There probably is an easy way, but I had to hack several bits out of p/Make-lang.in and Makefile.in, which whilst not difficult was not as easy as it possibly could be ...
You could try building the parts you want explicitly:
make xgpc gpc1 gpc-cccp
Most recent GPC versions should accept GCC_FOR_TARGET, the compiler used to build libgcc.a and libgpc.a
make CC=<your_cross_gcc> HOST_CC=<native_gcc> \ GCC_FOR_TARGET=<cross_gcc_for_target> ...
The latest GPC beta has part of the RTS in Pascal, but I just hacked in support for GPC_FOR_TARGET :-) Just wait for the next beta.
Needless to say you need various cross-compilers ready and installed to do all of this, but you knew that or you wouldn't try canadian cross.
I crossbuild native cygwin32 GPC compilers from Linux regularly.
Hope this helps,
JJ
--- With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC1925.