inline functions

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

inline functions

1,191件の閲覧回数
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 件の賞賛
返信
2 返答(返信)

1,094件の閲覧回数
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 件の賞賛
返信

1,094件の閲覧回数
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 件の賞賛
返信