function definition without parameter list

Alexander Bernauer bernauer at inf.ethz.ch
Mon Nov 5 13:58:37 GMT 2012


Hey,

the Language.C parser happily accepts the following code:
---8<---
int f {}
--->8---

and returns the following AST:
---8<---
(CTranslUnit
 [CFDefExt
    (CFunDef [CTypeSpec (CIntType _)]
       (CDeclr (Just "f") [] Nothing [] _) [] (CCompound [] [] _) _)]
 _)
--->8---

But the GCC rejects the code with
---8<---
/tmp/foo.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
--->8---

I am not aware of any language dialect of C that allows function
definitions without parameter lists. Is there any? Or should the parser
actually also reject the above code?

Greetings

Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://projects.haskell.org/pipermail/language-c/attachments/20121105/7c7d8112/attachment.pgp>


More information about the Language-c mailing list