Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd agree if GP hadn't also used C++-specific optional parameters. Given the minefield that is vendor specific C++ish extensions to C, it seems worth a mention, even if I'm unaware of a compiler vendor that allows default parameters in your C code.


It was just an illustration in C++ (the C version would just document it, obviously). There is no way to do this in a vendor specific way without some sort of name mangling that will hopelessly break the ABI...


Yes there is:

  void foo(void* p=0); // has exactly the same ABI as
  void bar(void* p);
  bar(); // error: missing parameter
  foo(); // shorthand for foo(0);
  // void(*)(void*) is a different type than void(*)(void*=0)
  // but they can be implicitly converted the same as
  // eg void* and char*


hmm I guess so!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: