That's pretty speculative. But one good reason is because void
is not an empty value; it's the absence of a value. For instance, a function with a signature of int f(void)
takes zero arguments, not one.
C/C++: Is there a specific reason why "void" was not simply defined as "typedef struct{} void" (i.e. an empty struct) with appropriate casting rules? [closed]
-
29-05-2022 - |
سؤال
As an aside: Such a standard typedef would have help reduce the number of reserved words in C/C++, and relegated void to a simple type declaration, e.g. in <stddef.h>. (c.f. SRB in AB33/Mar 1972 - PDF=7kB)
المحلول
لا تنتمي إلى StackOverflow