Friday, December 03, 2004

More on Inline in Delphi

Turns out Remco is the person I have been exchanging with about the inline warnings. He isn't too thrilled that he needs to use the {$IFDEF WINDOWS} directive. That is understandable. Most developers dislike the dreaded IfDef compiler directive.

What else can he do? Especially with his "do not use not used units" policy?

You have two other options to get rid of this warning without adding Windows to the uses clause (even though it is already included in your compiled application because you use SysUtils that uses Windows). What the warning is telling you is that although you (or another developer) specified that the function should be inlined, but because of your uses clause it cannot.

You can just tell the compiler to turn of inlining all together with the {$INLINE OFF} compiler directive. This ignores all those Inline directives on your functions. Remove all benefit and annoyance of this new feature.

The other option is the {$INLINE AUTO} compiler directive. This tells the compiler that you trust it to inline functions based completely on its judgment. This also ignores the Inline directives on your functions, but instead of disabling Inlining the compiler just makes all the decisions on its own. Interestingly, if I don't have a carriage return between $INLINE and AUTO then the error insight and Structure panel flags it as an Invalid compiler directive, but it compiles fine. Adding a carriage return fixes it.

Either directive removes the hint about not having the correct unit in your uses clause. {$INLINE ON}is the default compiler directive. This compiler directive is site specific. In other words you would need to added it to the top of each unit you want to change the behavior in. Alternatively you could just surround the procedure that makes the inline call in question with OFF and ON directives. Don't know if that is better then IfDef though.

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.