[fpc-devel] Inlining functions...

Vinzent Höfler JeLlyFish.software at gmx.net
Tue Jul 25 21:37:05 CEST 2006


Peter Vreman wrote:
> At 16:56 25-7-2006, you wrote:
>> Hi,
>>
>> some questions:
>>
>> 1) Is there some good reason why the support for the inline keyword can
>> be turned on and off explicitely by the {$INLINE} directive?
> 
> Historical

Oh, ok. There's no reason like the "historical reason". ;)

>> 2) Can I check somehow if inlining is enabled during compilation?
>> {$IFOPT INLINE} didn't work. ;)
> 
> You can't test it.

Too pity. The reason why I'm asking this is that I have some type/view 
conversion subroutines (more or less just for convinience) that could be 
inlined, because most of the times they do close to nothing.

So I'd like to give the hint to the compiler, but unless the switch is 
enabled, it refuses to compile, see transcript below. I just want to be 
independent of a particular setting of that switch.

 > Also the inline is only a hint for the compiler.

Alright, that's as it should be.

>> 2a) If the answer to 2) is "no", can we make the compiler to ignore it
>> like the "far" keyword? It's because, I'm quite used to the fact that
>> inline is merely a suggestion to the compiler, not taken as a command
>> to be obeyed all times.
> 
> What to ignore?

The "inline" keyword, if it is applied and neither -Si nor {$INLINE ON} 
have been specified for the compilation unit in question:

|C:\prj>type inline.pas
|procedure Null; inline;
|begin
|end {Null};
|
|begin
|   Null;
|end.
|
|C:\prj>fpc inline
|Hint: End of reading config file C:\fpc\bin\i386-Win32\fpc.cfg
|Target OS: Win32 for i386
|Compiling inline.pas
|inline.pas(2,1) Error: Procedure type INLINE not supported
|inline.pas(8) Fatal: There were 1 errors compiling module, stopping
|inline.pas(8) Fatal: Compilation aborted
|Error: C:\fpc\bin\i386-Win32\ppc386.exe returned an error exitcode 
|(normal if you did not specify a source file to be compiled)
|
|C:\prj>fpc -Si inline
|Hint: End of reading config file C:\fpc\bin\i386-Win32\fpc.cfg
|Target OS: Win32 for i386
|Compiling inline.pas
|Linking inline.exe
|7 Lines compiled, 0.1 sec
|
|C:\prj>fpc -iV
|2.0.2

It's not really that important, but if "inline" is handled as a hint 
anyway, throwing an error seems a bit overkill then.


Vinzent.



More information about the fpc-devel mailing list