Delphi 7 macro preprocessor support

泄露秘密 提交于 2019-12-10 10:37:20

问题


Is there a macro preprocessor for Delphi 7?

There isn't one built in so maybe there's a possibilty to use a third party or some other languages preprocessor (like c preprocessor).

If there's one, how to set it up for Delphi 7?

I'm trying to do function inlining (for speed). Macro preprocessor seems to be the only easy option for delphi.

Thanks, Egon


回答1:


You can always run an external macro processor, such as m4 or even (shudder) cpp on your code before you compile it. I wouldn't recommend this however - in my experience the benefits of inlining (which is what you seem to want to do) are quite small, and can be offset by slowdowns caused increases in code size.




回答2:


Here's how I used m4:

// uses lookup for counting bits
function PopCount(const Number: Cardinal): Byte;
begin
  Result := WordBitCount[Number and $FFFF] + WordBitCount[Number shr 16];
end;
{ M4 macro
define(PopCount, (WordBitCount[$@ and $FFFF] + WordBitCount[$@ shr 16]))
}

It's still easily compilable, but can be sped up with m4.




回答3:


You can use the [JEDI Pascal Preprocessor](JEDI Pascal PreProcessor) which is part of the JEDI Code Library.

You can fetch the current JCL release from its SourceForge project page, and you can browse the JPP course code here.




回答4:


I haven't heard of any third-party macros in Delphi 7, but versions 2007+ have automatic inlining if that's an option.



来源:https://stackoverflow.com/questions/1893989/delphi-7-macro-preprocessor-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!