Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Using the Lazarus IDE
»
Options
»
IFOPT and MObjPFC & MDelphi [SOLVED]
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
FPC Unleashed (inline var...
by
440bx
[
Today
at 11:38:36 pm]
ZeosDB and sqlite3
by
Prime
[
Today
at 10:34:48 pm]
Ann: Deinline: a de-inlin...
by
Thaddy
[
Today
at 09:37:18 pm]
Help with OLD code
by
Thaddy
[
Today
at 08:12:04 pm]
Lazarus Image Editor
by
wp
[
Today
at 08:02:15 pm]
fp-h2pas: New C header tr...
by
BildatBoffin
[
Today
at 07:22:29 pm]
The ever re-appearing /= ...
by
marcov
[
Today
at 05:58:29 pm]
TurboBird IBX
by
maurog
[
Today
at 04:10:32 pm]
Remote desktop software i...
by
gidesa
[
Today
at 02:25:43 pm]
Omitting semicolon on las...
by
Xenno
[
Today
at 02:04:31 pm]
I can write your README.m...
by
domasz
[
Today
at 09:53:02 am]
Can /my/ AI help me with ...
by
cdbc
[
Today
at 08:59:28 am]
android attack (inc)
by
speter
[
Today
at 04:19:54 am]
Little bit...
by
n7800
[
Today
at 03:51:08 am]
[ANN] Unofficial FPC 3.3....
by
440bx
[
Today
at 01:00:04 am]
NiceGrid component for La...
by
wp
[
Today
at 12:03:57 am]
Track windows cross-platf...
by
dsiders
[April 10, 2026, 07:43:43 pm]
[ANN] PasBuild v1.8.0 Rel...
by
Graeme
[April 10, 2026, 06:43:13 pm]
Подписи кнопок панели инс...
by
Raskaton
[April 10, 2026, 06:37:48 pm]
HTTPS-сервер с ГОСТ-серти...
by
Raskaton
[April 10, 2026, 06:29:36 pm]
Strange behavior with dat...
by
JanRoza
[April 10, 2026, 06:20:38 pm]
RegExpr matchting empty s...
by
Thaddy
[April 10, 2026, 04:35:27 pm]
TLazSerial : serial port ...
by
CM630
[April 10, 2026, 03:45:42 pm]
Can't pass string to TEdi...
by
lazarusprogrammer
[April 10, 2026, 02:04:36 pm]
Messing with Gemini AI an...
by
gidesa
[April 10, 2026, 12:48:03 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: IFOPT and MObjPFC & MDelphi [SOLVED] (Read 855 times)
DelphiDinosaur
New Member
Posts: 25
IFOPT and MObjPFC & MDelphi [SOLVED]
«
on:
September 01, 2025, 03:56:18 pm »
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]
[+]
[-]
AButton
:
TButton
;
{$IFOPT MDelphi}
AButton
.
OnClick
:
=
MyOnClickHandler
;
{$ELSE}
AButton
.
OnClick
:
=
@
MyOnClickHandler
;
{$ENDIF}
DD.
«
Last Edit: September 01, 2025, 04:06:22 pm by DelphiDinosaur
»
Logged
AlexTP
Hero Member
Posts: 2696
Re: IFOPT and MObjPFC & MDelphi
«
Reply #1 on:
September 01, 2025, 03:58:29 pm »
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.
Logged
CudaText editor
-
ATSynEdit
-
More from me
DelphiDinosaur
New Member
Posts: 25
Re: IFOPT and MObjPFC & MDelphi
«
Reply #2 on:
September 01, 2025, 04:05:43 pm »
Thanks for the help. This works nicely:
Code: Pascal
[Select]
[+]
[-]
{$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...
Logged
Thaddy
Hero Member
Posts: 18924
Glad to be alive.
Re: IFOPT and MObjPFC & MDelphi [SOLVED]
«
Reply #3 on:
September 01, 2025, 04:23:37 pm »
Better to reverse it:
Code: Pascal
[Select]
[+]
[-]
{$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)
«
Last Edit: September 01, 2025, 05:15:04 pm by Thaddy
»
Logged
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Using the Lazarus IDE
»
Options
»
IFOPT and MObjPFC & MDelphi [SOLVED]
TinyPortal
© 2005-2018