News for hackers. Stuff that matters.
Re:F() vs. F(void) in C vs. C++ by bpye on Sunday May 12, 2019 @07:01PM (#19895147)
Could introduce something new, foo(?) or such to make the intent clearer.
Re:F() vs. F(void) in C vs. C++ by userbinator on Sunday May 12, 2019 @10:09PM (#19895943)
There's already the "..." token to signify a variadic function, which is effectively what "takes parameters that you can't list" means, although I believe it's currently defined only for at least one non-variadic argument.
Re:F() vs. F(void) in C vs. C++ by int_19h on Sunday May 12, 2019 @10:35PM (#19896046)
Furthermore, on some architectures, vararg functions have their own distinct ABI, so (...) as a declaration is not compatible with any definition that doesn't also use (...).
Re:F() vs. F(void) in C vs. C++ by kazinator on Monday May 13, 2019 @01:33AM (#19896632)
The construct would be a pointless throwback to poorer type safety. Every C function call is statically typed and so is a function definition. The declaration of what is being called may tell you nothing about the argument list, but the call expression which uses that identifier will assume a static type for it, based on how it is called. The call will be compiled assuming it has a certain type, which may or may not match what is being called. There is no run time-check; if it's wrong, it's undefined behavior.
Re:F() vs. F(void) in C vs. C++ by Gibbon1 on Sunday May 12, 2019 @07:23PM (#19895264)
What I would like in C is a way to specify an argument list. And be able to slop them around and call functions with them later.

So perhaps foo(args) means foo takes a list of arguments unspecified.

Re:F() vs. F(void) in C vs. C++ by nitrogen on Sunday May 12, 2019 @11:42PM (#19896289)
You can approximate an argument list using compound literals as long as 0/NULL is an acceptable default value. It's a bit noisy, but it works something like this if I remember right:

    result = foo(&(struct foo_args){.arg1 = 4, .arg7 = "2"})
Re:F() vs. F(void) in C vs. C++ by ndesaulniers on Monday May 13, 2019 @03:19AM (#19896957)
Re:F() vs. F(void) in C vs. C++ by kazinator on Monday May 13, 2019 @02:15PM (#19902092)
There are libraries for this like GNU ffcall and libffi.
Re:F() vs. F(void) in C vs. C++ by Gibbon1 on Monday May 13, 2019 @03:01PM (#19902691)
Looked at those. Problem with libffi is it wasn't ported to a 32 bit arm. And the interface is 'clunkie'

I think what I want is llvm's blocks. Which isn't available in gcc.

Re:F() vs. F(void) in C vs. C++ by unilynx on Monday May 13, 2019 @03:10AM (#19896915)
Like va_list in vprintf ?
Re:F() vs. F(void) in C vs. C++ by saagarjha on Sunday May 12, 2019 @07:07PM (#19895182)
Yup, would totally be fine with that.