cancel
Showing results for 
Search instead for 
Did you mean: 

inline functions

luter
Associate II
Posted on December 08, 2005 at 06:35

inline functions

3 REPLIES 3
luter
Associate II
Posted on December 05, 2005 at 11:32

Hello.

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.

fggnrc
Associate II
Posted on December 06, 2005 at 03:51

Hello Luter.

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

luca239955_st
Associate III
Posted on December 08, 2005 at 06:35

This 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