inline functions

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

inline functions

1,189 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by AMJ on Fri Dec 02 22:11:36 MST 2011
inline function defined in the header file generates linker error. It seems like linker does not recognize __INLINE or just inline, and gives error saying "multiple definition". static __INLINE does not generate an error. Any idea what's going on?

Thanks
0 Kudos
Reply
2 Replies

1,092 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ToBeFrank on Sun Dec 04 22:07:44 MST 2011

Quote: FlySnake
2. static means "visible only in this file". If you declare static function or variable in header, then the function will be visible in all files where this header included but as a copy of the declaration.



Ignoring the variables, since we're talking inline functions copying is irrelevant and static inline is an acceptable solution.
0 Kudos
Reply

1,092 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by FlySnake on Sat Dec 03 02:06:11 MST 2011
1. Prevent multiple inclusion of the header:
#ifndef MAIN_H_
#define MAIN_H_
/* code */
#endif /* MAIN_H_ */

and  "multiple definition" will go away.
2. static means "visible only in this file". If you declare static function or variable in header, then the function will be visible in all files where this header included but as a copy of the declaration.
0 Kudos
Reply