[fpc-pascal] detect implementation / interface sections
David Emerson
dle3ab at angelbase.com
Thu Sep 24 23:53:00 CEST 2015
I tried sending this message two days ago, but it seems not to have gone
through. Trying again.
I like using include files, to break up big units into multiple files,
and also as macro-based templates.
One thing I do frequently is to put both the interface and the
implementation into one include file, and include it twice-- once in the
interface, and once in the implementation section of the unit. The
include file thus looks like this:
{$ifdef interface}
<type declarations>
{$endif}
{$ifdef implementation}
<code>
{$endif}
So my question-- right now I have to manually define and undefine the
symbols "interface" and "implementation" in each unit.
Is there a way to detect what section of a unit the compiler is in,
rather than using these user-defined symbols?
So in my include file(s), instead of writing {$ifdef interface} I would
write something that actually knows if an interface or implementation is
being compiled.
Ditto for initialization, finalization (although I use this much less
frequently)
Thanks!
~David.
More information about the fpc-pascal
mailing list