Checking compiler mode lazarus / 62-General ---------------------------------------------------------------------- MarkMLl · 2021-07-31 10:26 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? 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: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (* "Number theory compatible" implementation of the modulo operator, hopefully  to match the Python operator's characterisitics.*)operator >< (a, b: int64): int64; (* See https://forum.lazarus.freepascal.org/index.php/t opic,48549.msg349691.html#msg349691 *)(* In principle $modeswitch ISOMOD should fix the problem, but I don't know     *)(* what version of the compiler introduced it (I suspect later than 3.0.4).     *) begin  Result := abs(a) mod abs(b);  if (a < 0) and (Result<>0) then    Result := abs(b) - Resultend { >< } ;  MarkMLl ---------------------------------------------------------------------- Kays · 2021-07-31 10:44 Quote from: MarkMLl on July 31, 2021, 12:26:43 pmIs 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. Quote from: MarkMLl on July 31, 2021, 12:26:43 pmI'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.Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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. ---------------------------------------------------------------------- PascalDragon · 2021-08-01 11:05 Quote from: MarkMLl on July 31, 2021, 12:26:43 pmIs 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? The current mode of the unit is available as FPC_ define. Modeswitches themselves have no defines however (so you would not be able to detect {$MODE ISO}{$MODESWITCH ISOMOD-}. ---------------------------------------------------------------------- MarkMLl · 2021-08-01 12:56 Quote from: PascalDragon on August 01, 2021, 01:05:18 pmQuote from: MarkMLl on July 31, 2021, 12:26:43 pmIs 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? The current mode of the unit is available as FPC_ define. Modeswitches themselves have no defines however (so you would not be able to detect {$MODE ISO}{$MODESWITCH ISOMOD-}. Thanks for that, still useful. MarkMLl