[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Tinycc-devel Digest, Vol 103, Issue 1
From: |
Robert Clausecker |
Subject: |
Re: [Tinycc-devel] Tinycc-devel Digest, Vol 103, Issue 1 |
Date: |
Wed, 02 Nov 2011 17:29:13 +0100 |
Am Mittwoch, den 02.11.2011, 12:00 -0400 schrieb Ben Bacarisse
> > It seems that I discovered a bug in tcc. ANSI C allows declaration
> of
> > prototypes containing function pointers like this:
> >
> > void traverse(mystruct_t*, void(mycontent_t*));
> >
> > tcc currently rejects this giving an error "')' expected". This
> > equivalent prototype works:
> >
> > void traverse(mystruct_t*,void(*)(mycontent_t*));
> >
> > Is this a bug or a feature?
>
> The two prototypes are not equivalent. The first is a syntax error
> but
> the second one is fine -- provided you wanted to pass a pointer to a
> function that takes a mycontent_t pointer and returns nothing.
I asked some folks on #c on freenode and they told me to tell you that
section 3.5.4.3, paragraph 9 of the C89 standard specifies that this is
allowed. (Why else would both gcc and clang allow the first declaration
with or without the -std=c89 or -ansi flag?) Quote:
For each parameter declared with function or array type, its
type for these comparisons is the one that results from
conversion to a pointer type, as in $3.7.1.
I am not an expert on the C spec, but please have a look at it.
Here is an easier testcase that compiles:
int foo(int,int,int(int,int));
int foo(int a,int b,int f(int,int)) { return f(a,b); }
Yours, Robert Clausecker
- Re: [Tinycc-devel] Tinycc-devel Digest, Vol 103, Issue 1,
Robert Clausecker <=