[fpc-devel]C style

Peter Vreman peter at freepascal.org
Fri Jan 12 16:58:04 CET 2001


> > Macro's with parameters aren't implemented becuase they can be replaced better with
inline
> > functions. IIRC there was also a note from Linus on the kernel list prefere a solution
> > with static;inline functions above a macro, because inlining also adds more type
safety.

> 
> How are the inline-functions implemented in FPC? When using macros, I can

inline should already work (but not tested by the masses yet) within units/programs. But
can't be placed yet in the interface section to be inlined across units.

> have (for example) two versions of it, one stub (empty) and one having
> some code on it. Good for debugging, since when compiled with no debug,
> no extra code gets generated.
> 
> As far as I understand, the above is not possible (in exactly same
> way) with inlined functions, since a reference to a function (which
> would not exist) generates an error.

function debugstr(s:string);inline;
begin
{$ifdef DEBUG}
  writeln(s:string);
{$endif}
end;

With optimization the empty inlined function can then be removed. But that afaik not yet
in the compiler

> 
> So the question is: Does an stub inline function with no code except
> for "begin end;" generate 'extra' code?

Not yet, but it can be added






More information about the fpc-devel mailing list