typedef func *func();

T

Till Backhaus

Hi comp.lang.c,

sorry for the subject of this message not being valid c, anyway this
is the shortest and cleanest way to describe my problem.
To put in other words:
I'm searching for a way to declare functions that return function
pointers of it's own type.
(Yes, I know of void-pointers, I just don't wan't loose type-checking if
I don't have to.)

Cheers,
Till Backhaus
 
R

Richard Bos

Till Backhaus said:
sorry for the subject of this message not being valid c, anyway this
is the shortest and cleanest way to describe my problem.
To put in other words:
I'm searching for a way to declare functions that return function
pointers of it's own type.

Not possible.
(Yes, I know of void-pointers, I just don't wan't loose type-checking if
I don't have to.)

They'd have been useless to you anyway.

Read the FAQ: <http://c-faq.com/decl/recurfuncp.html>.

Richard
 
D

dcorbit

Till said:
Hi comp.lang.c,

sorry for the subject of this message not being valid c, anyway this
is the shortest and cleanest way to describe my problem.
To put in other words:
I'm searching for a way to declare functions that return function
pointers of it's own type.
(Yes, I know of void-pointers, I just don't wan't loose type-checking if
I don't have to.)

Cheers,
Till Backhaus

Maybe RTTI in C++ would help. There is nothing like that in C.

What exactly is the problem you are trying to solve? Maybe there is a
simple solution in the C language from anther track.
 
J

Jack Klein

Hi comp.lang.c,

sorry for the subject of this message not being valid c, anyway this
is the shortest and cleanest way to describe my problem.
To put in other words:
I'm searching for a way to declare functions that return function
pointers of it's own type.
(Yes, I know of void-pointers, I just don't wan't loose type-checking if
I don't have to.)

Cheers,
Till Backhaus

Can't be done directly. Can be done using a structure with a function
pointer as its only member. Return an instance of the structure.

Coding is rather icky and left as an exercise to the reader, with the
hint that typedef comes in handy.

See http://c-faq.com/decl/recurfuncp.html in the FAQ, how did you miss
it?
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top