[prev in list] [next in list] [prev in thread] [next in thread]
List: pcc-list
Subject: Re: Function declarations without return type fails compiling.
From: Anders Magnusson <ragge () ludd ! ltu ! se>
Date: 2010-05-31 5:50:30
Message-ID: 4C034E26.1040403 () ludd ! ltu ! se
[Download RAW message or body]
Morning,
Jesus Sanchez wrote:
> ---Function declarations without return type fails compiling.
>
> Declaring a function ("func" for instance) without return type makes
> PCC fail at compiling. PCC seems to dont make assumptions with
> declarations and defaulting "int" as return type, but with function
> definitions it works. Is this a c99 feature? I haven't found anything in
> ISO/IEC 9899:TC3 so I wonder if I'm messing things up.
>
> anyway here's a example of code that fails compiling.
Other people has already responded, but I can give the reasons it don't
work
in pcc anymore:
- Just typing "func(); " to declare is very uncommon and would clutter
up the
parsing code even more, so I removed it when prototype support was added.
- "func(); " matches different rules in yacc than "func(){}", and the
latter seems to
still be used so I left it.
- "func(){}" is still allowed in C99 (see 6.11) but "func(); " is not
mentioned.
-- Ragge
> ------------------------------------------------------------------------
> #include <stdio.h>
>
> // simple declaration without return type
> // i'm supposing int as return type
> func(); // ERROR doesn't compile with PCC
>
> // simple definition of func that only returns 1
> func(){ // works on PCC
> return 1;
> }
>
> int main(){
> return 0;
> }
> ------------------------------------------------------------------------
>
> Thanks for your time.
> -J
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic