Delphi region compiler directive - backward compatible files?

Given the desire to use the useful Region compiler directive in module files, what is the best approach to use the same units in previous versions of Delphi? There seems to be no β€œdecent” approach. (Desired IDE Version - Delphi 7)

I like to have regions over method definitions to hide / show method definition hints and comments on version history, but I would have to surround Region directives with other compiler directives that seem to kill the β€œcleanup” of region compiler directives.

I assume that a preprocessor could be written to comment on all Region / EndRegion directives if you are using a version of Delphi that does not support regions .. and then adds back for later versions?

I have not 100% switched to Delphi 2009 and must support multiple versions of the IDE.

+3
source share
2 answers

I assume that D7 does not want to copy {$ REGION} or {$ ENDREGION}? I have only D2007 / 9 installed and cannot verify this.

Try the following:

{$IFDEF undef}{$REGION 'bla'}{$ENDIF}
//some code
{$IFDEF undef}{$ENDREGION}{$ENDIF}

D2009 Editor creates the region as expected. D7 should ignore $ REGION / $ ENDREGION if "undef" is not defined.

+9
source

Delphi (7), - . , GExperts .

, {$ I}, .

0

Source: https://habr.com/ru/post/1706651/


All Articles