Page 1 of 1
what's the intrinsical difference between them?
Posted: Thu May 29, 2003 7:40 am
by cxsnew
I am very perplexed about the difference between:
static __inline__ int func1() and
extern __inline__ int func2()
Pls delete this post if same questions have been posted before here,I am very sorry that I don't know how to use the search function of this board
Re:what's the intrinsical difference between them?
Posted: Thu May 29, 2003 8:23 am
by Pype.Clicker
static __inline__function() {...} just means that the function will not be viewable for outer modules (in the linker way of the word, i.e. other .o files). This has two usages:
- as the function is only seen within its own module, it can be declared in many modules, which is mandatory for an inline function
- if no instruction of the current module request the *address* of the function (but just call it), and if every function call have been inlined by the compiler, then there is no code emitted for the inline function itself (and there is no need for emitting it
extern __inline__ F() is a bit jerky. Because it both means that F is function that can be inlined, and that the function is not described just here. Imho, its only use is for function declaration prior to their definition:
Code: Select all
extern __inline__ F(type1, type2);
// some code that calls F(type1, type2)
static __inline__ F(type1, type2) {
...
}
though i dunno whether __inline__ F(type1, type2); would have given the same result or not, but i fear the compiler would have issued a "globally-viewable symbol F()" in that case.