C99 says (6.7.5.3p10): "The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters"
-
-
Replying to @davmac314 @sgrif
(so there definitely *is* such a thing as a no-arg function. But you do have to explicitly put "void" rather than an empty parameter list).
1 reply 0 retweets 2 likes -
Replying to @davmac314 @sgrif
If I recall, the distinction only exists in declarations. In a function definition, an empty list is equivalent to 'void'.
2 replies 0 retweets 0 likes -
Replying to @GL_DONT_CARE @sgrif
No; the form used in the definition acts as an equivalent declaration, so no parameter list acts allows calls which supply parameters ( = UB at run time, which is broken, yes).
1 reply 0 retweets 0 likes -
Replying to @davmac314 @sgrif
That's not how I read it: C99.7.5.3-p14: "An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters."
1 reply 0 retweets 0 likes -
C99.7.5.3-p14: "The empty list in a function declarator that is not part of a definition of that function specifies that no information about the number or types of the parameters is supplied."
1 reply 0 retweets 0 likes -
Replying to @GL_DONT_CARE @sgrif
Hmm. 6.9.1p7: "If the declarator includes a parameter type list [...]; such a declarator also serves as a function prototype for later calls to the same function in the same translation unit" - so - 1/
1 reply 0 retweets 0 likes -
- that implies if it doesn't include a parameter type list, then it doesn't serve as a function prototype, i.e. it's the same as a declaration with no parameter list. So while it "specifies that ... function has no parameters", it doesn't serve as a prototype - 2/2
1 reply 0 retweets 0 likes -
(so if you don't put "void", then you can still call the function and supply parameters, even though that's UB. This is what GCC does. If you supply "void" OTOH, you get an error).
1 reply 0 retweets 0 likes -
Replying to @davmac314 @sgrif
C99-6.2.1: "A function prototype is a declaration of a function that declares the types of its parameters." I argue that (a function declarator that specifies the function has no parameter) declares (the types of the parameters of the function). Sounds reasonable to me... no?
2 replies 0 retweets 0 likes
Can y'all untag me from this?
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.