Function pointers and inline definitions

R

raphfrk

This is probably not possible, but I thought I would ask.

Assuming that there is a function that takes a pointer to a function
as an input. Can the passed function be defined inline.

For example:

void func_func( void (*func_tst)( int ) , int a )
{

(*func_tst)( a );

}

int main( int argc, char **argv )
{

func_func(
(void (*) (int a))
{
printf( "%n" , a );
},
7
);

}

The effect would be that func_func would call the inlined function and
pass it 7.
 
B

Ben Bacarisse

This is probably not possible, but I thought I would ask.

Assuming that there is a function that takes a pointer to a function
as an input. Can the passed function be defined inline.

When I read this, I though "yes" because a "function defined inline"
might mean a function whose definition includes the qualifier "inline"
and that is possible. However...
For example:

void func_func( void (*func_tst)( int ) , int a )
{

(*func_tst)( a );

}

int main( int argc, char **argv )
{

func_func(
(void (*) (int a))
{
printf( "%n" , a );
},
7
);

}

The effect would be that func_func would call the inlined function and
pass it 7.

No, not possible. I'd call this a "function literal" rather than an
inlined function but, whatever you call it, you can't do it in
standard C.
 
R

raphfrk

No, not possible. I'd call this a "function literal" rather than an
inlined function but, whatever you call it, you can't do it in
standard C.

Bah :). Thanks for the info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top