In one header file, i have a inline function define like bellow:
extern CMODEXPORT int FMI_invoke_delete_as_class
(
FEATURE_RECORD_p_t frec, /* I: Feature record */
FMI_delete_fn_p_t fn /* I: Function pointer */
);
template<class T>
inline int FMI_invoke_delete_as_class(FEATURE_RECORD_p_t frec) // I: Feature record
{
class FMIHelper
{
public:
static int DeleteParms(FEATURE_RECORD_p_t frec)
{
//....
return error;
}
};
return FMI_invoke_delete_as_class(frec, &FMIHelper::DeleteParms);
}
In the last line, there is a call of FMI_invoke_delete_as_class
This function is defined in another .c file like
extern int FMI_invoke_delete_as_class
(
FEATURE_RECORD_p_t frec, /* I: Feature record */
OM_class_t class_id /* I: Object class */
)
{
//...
}
extern int FMI_invoke_delete_as_class
(
FEATURE_RECORD_p_t frec, /* I: Feature record */
FMI_delete_fn_p_t fn /* I: Function pointer */
)
if the declare of FMI_invoke_delete_as_class in header file is before inline function like i posted, inline funtion’s call is ok. However if i put that declaration after that inline function, it calls the wrong function in .c file.
I don’t know why, just happens under linux.
I tryed with following code:
and
and printed result is:
It seams ok. How do you invoke inline function? How are your type definitions? Which is your compile command? I’m using
g++ (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)withg++ -g -o kk kk.cppcommand line