Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Function pointers and inline definitions

Reply
Thread Tools

Function pointers and inline definitions

 
 
raphfrk@gmail.com
Guest
Posts: n/a
 
      12-09-2009
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.
 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      12-09-2009
"(E-Mail Removed)" <(E-Mail Removed)> writes:

> 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.

--
Ben.
 
Reply With Quote
 
 
 
 
raphfrk@gmail.com
Guest
Posts: n/a
 
      12-09-2009
On Dec 9, 2:29 pm, Ben Bacarisse <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
in-class function definitions, inline Hicham Mouline C++ 1 01-31-2008 12:58 PM
How to know the inline-function was implemented the inline way or normal way? ypjofficial@indiatimes.com C++ 7 07-18-2006 11:22 PM
forcing compiler to consider inline function inline. Ajay C++ 5 04-01-2006 02:03 PM
Use of inline function in inline function - is it allowed? TGOS C Programming 3 02-28-2005 10:49 AM
Function delcared inline but not defined inline Nish C Programming 4 10-08-2004 03:31 PM



Advertisments