In C a function declared as func() should be treated as having an unspecified number of untyped parameters, but SDCC compiler reports error 101: too many parameters.
I just checked, and at least your first example is indeed still valid C. An empty parameter list is still allowed in the latest C23 draft, despite already being listed as obsolescent in the very first C standard (ISO C90, section 6.9.4).
SDCC should compile the code, but emit a warning (the non-normative Annex I of the C standard recommends a warning).
Also, I should submit a proposal to WG14 to remove this from C23.
Last edit: Philipp Klaus Krause 2021-05-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are you being pedantic that you want this supported just because the standard allows it? Or do you really want to use it? And if so, why o why? This violates good design patterns!
SDCC should never support this IMHO. I vote to reject this bug.
Maarten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I looked into making this work for function calls with parameters today.
The attached patch should do so at the AST level.
But iCode generation and code generation currently still expect a function prototype with matching parameters, and would thus need work, too.
Below an example of a code that should compile without errors.
Last edit: Rajmund Szymański 2021-05-06
I just checked, and at least your first example is indeed still valid C. An empty parameter list is still allowed in the latest C23 draft, despite already being listed as obsolescent in the very first C standard (ISO C90, section 6.9.4).
SDCC should compile the code, but emit a warning (the non-normative Annex I of the C standard recommends a warning).
Also, I should submit a proposal to WG14 to remove this from C23.
Last edit: Philipp Klaus Krause 2021-05-06
In example below:
compiler reports error 78: incompatible types.
Rajmund,
Are you being pedantic that you want this supported just because the standard allows it? Or do you really want to use it? And if so, why o why? This violates good design patterns!
SDCC should never support this IMHO. I vote to reject this bug.
Maarten
Its in the current C standard, so SDCC should support it. Not being standard-compliant is a bug.
No problem. I'm using this feature in my RTOS project. SDCC was one of the supported compilers.
I looked into making this work for function calls with parameters today.
The attached patch should do so at the AST level.
But iCode generation and code generation currently still expect a function prototype with matching parameters, and would thus need work, too.