Re: void parameter argument



AFAIK, the syntax

void function_name(void)

was introduced in ANSI C (or perhaps earlier) because the old, original
K&R C allowed function prototypes with "unspecified" arguments. So, in
C you could also say,

void function_name()

which did _not_ mean "this function does not take any arguments," but
rather "I'm not telling you what arguments this function takes, if
any." So, the "(void)" syntax was a necessary addition to distinguish
between this non-disclosure and a declaration that a function took no
arguments. It was a backward compatibility thing.

I suppose that it was left out in C# because it's superfluous. In a
language that requires you to declare all arguments, there's no need to
distinguish between the two cases with a keyword "void".

.



Relevant Pages

  • failed build for tk-8.4.5,1 and bittorrent
    ... error: syntax error before "ClientData" ... error: syntax error before "VOID" ... syntax er ror before "int" ... error: ...
    (freebsd-questions)
  • Re: What is a null pointer constant?
    ... > NULL] thus NULL would act as an object macro yet #NULL would be "(void ... I would argue that a null pointer constant surrounded by ... > parentheses is still valid for initialization on the grounds that ... It's determined entirely by the syntax of the expression, ...
    (comp.std.c)
  • Re: Compile Errors
    ... Would it affect syntax for function prototypes? ... You need to remove the void, ...
    (comp.lang.c)
  • Re: would C be easier to read if...
    ... "pointer to function taking a void * argument and returning void ... easy-to-read syntax for C type declarations. ... you'd have to go back to the type system itself and look at it. ... pointers to any function signature. ...
    (comp.lang.c)
  • Re: Casting function pointers
    ... int taskCreate(char* taskName, void* funcPtr, int ... The clear syntax reveals a clear thought. ...
    (comp.arch.embedded)

Loading