Skip to content

[c language] Answer to "what is optional in a function declaration" is only correct for C23 #7094

Open
@uap-universe

Description

@uap-universe

The following answer is only correct for C23.

#### Q13. What is optional in a function declaration?
- [ ] data type of parameters
- [ ] return type of function
- [x] parameter names
- [ ] number of parameters
[Reference](https://www.cprogramming.com/tutorial/c/lesson4.html)

Before C99, all four have been optional. Starting with C99, the parameter names and the number of parameters are still optional.

The following declaration declares the function with an unknown number of parameters (but without declaring a prototype):

int f();

With C23 this was changed to be equivalent to the following declaration:

int f(void);

In C17, for example, this is perfectly valid while it does not compile with C23:

int f();

int f(int x) { return x*2; }

See also: cppreference

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions