Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7545295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:53:25+00:00 2026-05-30T08:53:25+00:00

In one header file, i have a inline function define like bellow: extern CMODEXPORT

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:53:27+00:00Added an answer on May 30, 2026 at 8:53 am

    I tryed with following code:

    /** kk.h */
    #include <iostream>
    struct FEATURE_RECORD_p_t
    {
        int kk;
    };
    
    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)
                {
                    //....
                    std::cout << "DeleteParms" << std::endl;
                    frec.kk = 100;
                    return frec.kk;
                }
        };
    
        std::cout << "FMI_invoke_delete_as_class<>" << std::endl;
        return FMI_invoke_delete_as_class(frec, &FMIHelper::DeleteParms);
    }
    
    typedef int (*FMI_delete_fn_p_t)(FEATURE_RECORD_p_t);
    
    extern int FMI_invoke_delete_as_class
    (
        FEATURE_RECORD_p_t frec,     /* I: Feature record */
        FMI_delete_fn_p_t  fn        /* I: Function pointer */
    );
    

    and

    #include "kk.h"
    extern int FMI_invoke_delete_as_class
    (
        FEATURE_RECORD_p_t  frec,     /* I: Feature record */
        int                 class_id  /* I: Object class */
    )
    {
        std::cout << "FMI_invoke_delete_as_class (bad)" << std::endl;
        return 0;
    }
    
    extern int FMI_invoke_delete_as_class
    (
        FEATURE_RECORD_p_t frec,     /* I: Feature record */
        FMI_delete_fn_p_t  fn        /* I: Function pointer */
    )
    {
        std::cout << "FMI_invoke_delete_as_class" << std::endl;
        return fn(frec);
    }
    
    int main()
    {
        FEATURE_RECORD_p_t kk;
    
        FMI_invoke_delete_as_class<int>(kk);
        return 0;
    }
    

    and printed result is:

    FMI_invoke_delete_as_class<>
    FMI_invoke_delete_as_class
    DeleteParms
    

    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) with g++ -g -o kk kk.cpp command line

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one header file which uses a virtual function. This is declared and
I have one map within one header file class: class One { // code
In one header file I have: #include BaseClass.h // a forward declaration of DerivedClass,
I'd like to create a Makefile.am file which generates one header file mentioned in
I have a 2 modules (.c files) and one .h header file: file1.c: #include
I have a header file containing a lot of small inline functions. Most of
I will have two files. One header.h file and second one is main.c file.
Here is one of my header file which consists of a union template with
I am using Struts Tiles with JSF to have one header, menu and footer
I have 2 tables in separate <div> 's. One is the header and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.