Alex Rivera | Logout

Is it possible to typedef a pointer-to-extern-"C"-function type within a template?

Asked 2011-02-01T18:25:11.317
9

I want to add a public typedef to a template for a pointer to a function-taking-one-argument that uses "C" language linkage.

I tried:

extern "C" {
    template <typename return_t_, typename arg1_t_>
    struct test
    {
        typedef return_t_ (*C_fun1_t)(arg1_t_);
    };
}

And:

template <typename return_t_, typename arg1_t_>
struct test
{
    extern "C" {
        typedef return_t_ (*C_fun1_t)(arg1_t_);
    }
};

And:

template <typename return_t_, typename arg1_t_>
struct test
{
    extern "C" typedef return_t_ (*C_fun1_t)(arg1_t_);
};

without success.

Is what I am trying to accomplish possible?

Edit
Report

1 Answer

1

Consider typedef of a boost::function or the STL function objects ... also you can't define a template inside a extern "C" block for some quite obvious reasons if you think about it.

answered 2011-02-01T18:39:08.147

Your Answer