On 03-08-08 17:38, rahul p wrote:
On Sun, Aug 3, 2008 at 7:36 PM, Rene Herman
<rene.herman@xxxxxxxxxxxx <mailto:rene.herman@xxxxxxxxxxxx>> wrote:
In C, except as an operand of sizeof or unary &, an expression
having function type is automatically converted from function type
to pointer to function.
Or put differently: except for sizeof and unary &,
"function_designator" and "&function_designator" are
interchangeable as expressions.
Thanks Rene. Plz discard my earlier msg as I didn't get question then.
Yes it's the case with the fuctions. Just a small detail. They aren't
interchangeable. "&function_designator" cannot be used in place of
"function_designator". Correct me if I am wrong.
As per my own followup, the specific thing I said was indeed wrong at
that point but otherwise, with:
void foo(void);
the expression "foo", other than for sizeof(foo) and &foo, has the same
value as the expression &foo. Specifically, with:
int (*bar)(void);
"bar = foo;" and "bar = &foo;" definitely make bar end up with the same
value. Also, if we have a function that takes this function as a parameter:
void func(void (*bar)(void));
calling func(foo) and func(&foo) do the same thing and neither should warn.
Moreover, with:
typedef void (foo_t)(void);
We say that foo_t is a function returning void, and:
void func(foo_t bar);
says that func is a function taking a function returning void as a
parameter. When we actually call func(foo) though, foo is automatically
converted into _a pointer_ to a function returning void, so func might
as well have been declared as void func(foo_t *bar);
I expect that someone who enjoys reading the C standard more than I do
could've given this answer in a single sentence (be it an unparseable
one) but I believe what I should've said instead was just that
void func(foo_t bar);
and
void func(foo_t *bar);
are interchangeable.
Rene.
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ