News for hackers. Stuff that matters.
Re:Be wary of functions which take several parameters of the... by friend-monoid on Friday September 27, 2019 @04:34AM (#21089714)
As C:

  struct copy_args_s {
    char * src;
    size_t src#;
    char * dest;
    size_t dest#;
  };
  int copy(struct copy_args_s args) {
    ...
  }
  int main() {
    copy((struct copy_args_s){ .src = "foo", .src_len = 3, .dst = "bar", .dst_len = 3 });
  }

Or with some macro magic:

  struct copy_args_s {
    char * src;
    size_t src#;
    char * dest;
    size_t dest#;
  };
  int copy(struct copy_args_s args) {
    ...
  }

  #define copy(...) copy((struct copy_args_s){__VA_ARGS__})

  int main() {
    copy(.src = "foo", .src_len = 3, .dst = "bar", .dst_len = 3);
  }
Re:Be wary of functions which take several parameters of the... by coldpie on Friday September 27, 2019 @08:34AM (#21091182)
> Or with some macro magic

Stop! Put down the editor and step away from the compiler, please. No one wants to get hurt.