logoalt Hacker News

1718627440last Monday at 1:40 PM2 repliesview on HN

But

    typedef void * (type) (void * args);

    type foo;

    a = foo (b);
works?

Replies

meindnochlast Monday at 3:11 PM

Those are function pointers. Your parent was referring to the function type. Per ISO/IEC 9899:TC3:

A function type describes a function with specified return type. A function type is characterized by its return type and the number and types of its parameters. A function type is said to be derived from its return type, and if its return type is T , the function type is sometimes called ‘‘function returning T’’. The construction of a function type from a return type is called ‘‘function type derivation’’.

show 1 reply
gpderettalast Monday at 3:31 PM

This is true, in both C++ and C, you can use a function type to declare (but not define) a function! This pretty much never comes up and I forgot.

edit: you literally said this in your original comment. I failed at reading comprehension.

show 1 reply