I was reading about inline functions in C/C++ from:
For the following code:
inline.h:
#include<stdio.h>
extern inline void two(void){ // GNU C uses this definition only for inlining
printf("From inline.h\n");
}
main.c:
#include "inline.h"
int main(void){
void (*pTwo)() = two;
two();
(*pTwo)();
}
two.c:
#include<stdio.h>
void two(){
printf("In two.c\n");
}
The output is given as :
From inline.h
In two.c
It says that this output is obtained for "Using the gcc semantics for the inline keyword".
How is version of two() function to be called decided in case one of the versions is inlined?
As i can see from the output, the inlined version is called with two() is directly invoked i.e. without any function pointer. Whereas, when a function pointer is used, the non-inlined version is called. Is there a general rule for resolving such calls?
two.c.