IFOPT and MObjPFC & MDelphi [SOLVED] lazarus / 11-Options ---------------------------------------------------------------------- DelphiDinosaur · 2025-09-01 13:56 I have code that's shared between projects, some compile with the Object Pascal (MObjFPC) syntax mode, other use the Delphi (MDelphi) syntax mode as they use older shared Delphi 6 code. Is there a way of using $IFOPT to toggle code between the two syntax models? I need this to toggle between event assignment methods: e.g. 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 AButton: TButton;{$IFOPT MDelphi}AButton.OnClick := MyOnClickHandler;{$ELSE}AButton.OnClick := @MyOnClickHandler;{$ENDIF}  DD. ---------------------------------------------------------------------- AlexTP · 2025-09-01 13:58 Answer from AI Mistral: To check the syntax mode, you should use $IFDEF with the predefined symbols FPC and DELPHI, or more specifically, FPC_OBJFPC for Object Pascal mode and FPC_DELPHI for Delphi mode. ---------------------------------------------------------------------- DelphiDinosaur · 2025-09-01 14:05 Thanks for the help. This works nicely: 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 {$IFDEF FPC_OBJFPC}AButton.OnClick := @MyOnClickHandler;{$ELSE}AButton.OnClick := MyOnClickHandler;{$ENDIF}  I'd assumed it would work along the same lines as {IFOPT D+} for debug mode... ---------------------------------------------------------------------- Thaddy · 2025-09-01 14:23 Better to reverse it: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 {$if defined(FPC_DELPHI) or defined(FPC_TP)}  writeln('Mode delphi');{$elseif defined(FPC_OBJFPC)}  writeln('Mode ObjFpc');{$elseif defined(FPC_FPC)}  writeln('Mode FPC');{$ifend} That is because Delphi mode is the exception, Almost all other modes use the @. Explicit Pointer dereferences (Except mode FPC_TP)