Re: Strange C constructs

Derek M Jones <derek@NOSPAMknosof.co.uk>
2 Mar 2004 11:05:45 -0500

          From comp.compilers

Related articles
Strange C constructs vbdis@aol.com (2004-02-26)
Re: Strange C constructs derek@NOSPAMknosof.co.uk (Derek M Jones) (2004-02-26)
Re: Strange C constructs iddw@hotmail.com (2004-02-27)
Re: Strange C constructs jeremy@jdyallop.freeserve.co.uk (Jeremy Yallop) (2004-02-27)
Re: Strange C constructs alexc@std.com (Alex Colvin) (2004-02-27)
Re: Strange C constructs derek@NOSPAMknosof.co.uk (Derek M Jones) (2004-03-02)
Re: Strange C constructs david.thompson1@worldnet.att.net (Dave Thompson) (2004-03-02)
Re: Strange C constructs vbdis@aol.com (2004-03-02)
Re: Strange C constructs viz@pisem.net (Victor Zverovich) (2004-03-02)
Re: Strange C constructs RLake@oxfam.org.pe (2004-03-06)
Re: Strange C constructs nmm1@cus.cam.ac.uk (2004-03-11)
| List of all articles for this month |
From: Derek M Jones <derek@NOSPAMknosof.co.uk>
Newsgroups: comp.compilers
Date: 2 Mar 2004 11:05:45 -0500
Organization: Knowledge Software
References: 04-02-147 04-02-163 04-02-167
Keywords: C, standards
Posted-Date: 02 Mar 2004 11:05:45 EST

Jeremy,


>>> Another question may be easier to answer:
>>>
>>> typedef int (procname)(int arg);
>>>
>>> According to K&R only /pointers/ to procedure-types can be constructed.
>>
>> Hang on. I thought you were a fan of standards?
>>
>>> Does there exist newer specs which allow to typedef procedures
>>> themselves?
>>
>> If you mean C99, then no. If you mean vendor extensions, I cannot
>> think of any.
>
> Hmm? Function types can certainly be typedef-ed in C99 (and C89). I
> do it quite often, in fact, since I dislike hiding the fact that
> there's a pointer involved:
>
> typedef void comparison_t(const void *, const void*);
> void sort(void *sequence, size_t length, comparison_t *compare);


You are right, I was being overly restrictive. Given the above
declarations it is not possible to write:


comparison_t f
{
}


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.