I try inline fucntion with Cosmic, but get problem. if i define function and use it in the same file --everything is going well, e.g. @inline void InLineFunc(void) { Nop; } main () { InLineFunc(); } But if i place call and definition of the inline fuction in different files i am getting error messages. I took into account ''C Cross Compiler User’s Guide'' page 61, but without success. How should I define this function in .h file or any other suggestions? Tnx in advance.
An inline function is like a pre-processor macro: each call to an inline function is replaced by the function body. This increases code speed (and code size too). You can not have a pointer to an inline function and therefore you can not call it from outside of the source file where it is defined. Bye EtaPhi
Posted on December 08, 2005 at 06:35This may appear obvious, but I thought I would say it anyway: drawing the conclusion of what EtaPhi says, if you want to use the same inline function in several C files, the only solution is to define it in an header file that is included in all the C files; the definition to use in the header is exactly the same that you would use in the C file (no need for ''extern'' or any other special keyword). Regards, Luca