Inline functions in Lite-C

Posted By: Zheka

Inline functions in Lite-C - 01/19/18 13:35

Hello,

Does Lite-C support function definitions as "inline"?

If yes, what's the correct way?

TX!
Posted By: Spirit

Re: Inline functions in Lite-C - 01/20/18 14:31

The lite-C functions are all called, no inline.
Posted By: frankjiang

Re: Inline functions in Lite-C - 01/22/18 03:21

I think Lite-C just Script,so without inline.
Posted By: MasterQ32

Re: Inline functions in Lite-C - 01/22/18 08:29

Lite-C does not known "functions" in C-Terms, but only "function pointers".

If you write
Code:
function foo()
{
  error("foo");
}
function bar()
{
  error("bar");
}



you have declared two function pointers foo and bar (which you can swap):

Code:
...
void * tmp = foo;
foo = bar;
bar = foo;

foo(); // will call error("bar")
bar(); // will call error("foo")
...



This allows monkey patching functions for your own needs laugh

Also: Function Prototypes (without definition) will not have the value NULL but a special value that will error "empty function called in ..."
Posted By: Zheka

Re: Inline functions in Lite-C - 02/18/18 14:15

Oh, nice to know, thanks!

Though my question was rather aiming at avoiding the overhead of usual function calls.
Posted By: MasterQ32

Re: Inline functions in Lite-C - 02/18/18 20:04

Quote:
Though my question was rather aiming at avoiding the overhead of usual function calls.

Afaik Lite-C does no optimizations what so ever, so don't get your hopes up
Posted By: Zheka

Re: Inline functions in Lite-C - 02/19/18 20:26

I don't...already.
© 2024 lite-C Forums