Is there a compile-time check which will show whether the current mode is one in which the mod operator will work in accordance with the ISO Pascal definition?
No. As you probably already know, the
{$ifOpt} directive only works on settings a short/single-letter alternative exists for.
I'm aware of -Miso and {$modeswitch ISOMOD } , but at a particular place in the code I want to know whether one of these is active and if not use a custom operator: […]
Simply
always use the “custom” operator. Write a
separate unit in which you “overload”, for instance, the
>< operator
in any case, yet this unit has
{$modeSwitch ISOMod+} at the top.
unit foo;
{$modeSwitch ISOMod+}
{$modeSwitch result+}
interface
operator >< (const x: ALUSint; const y: ALUUint): ALUUInt;
implementation
operator >< (const x: ALUSint; const y: ALUUint): ALUUInt;
begin
result := x mod y;
end;
end.
The
unit can be compiled in
any compiler compatibility mode (that supports units and operator overloading), but will always use an ISO-compliant definition of
mod.
The ISO-compliant definition of
mod exists for
almost ten years now, basically
since {$mode ISO} was supported in 2.6.0. The
{$modeSwitch ISOMod+}, however, exists for
over 5 years now. It was not available in 3.0.0. The most recent git
test conversion stops tagging at 3.0.0RC1, so I can’t make any definite statement, whether it was available in 3.0.4.