News for hackers. Stuff that matters.
Re:C String Creation by hthh on Thursday February 11, 2016 @06:36PM (#11084215)
This is an interesting article, but the "Portability" comments could be a lot more useful: strndup and open_memstream are both "POSIX 2008", but strndup can be used on OS X while open_memstream cannot.
Re:C String Creation by sortie on Friday February 12, 2016 @02:58AM (#11085862)
I deliberately didn't write that to avoid the page going stale when OS X adds it. But OS X is behind the times and that's harmful. POSIX 2008 has been out for years and most of the lacking features are trivial to add. They're being actively harmful to Unix software by not having modern interfaces, forcing portable software to be worse. The purpose of the article is to highlight the interfaces, and when they're suited, rather than being a replacement for your system manual page or a portability guide. Since OS X isn't a free software Unix (though its libc is), I don't really consider it among the relevant modern Unix systems. Linux, the BSDs, and so on all have the POSIX 2008 features mentioned here.
Re:C String Creation by apaprocki on Thursday February 11, 2016 @07:07PM (#11084393)
While not immediately clear, OS X is POSIX 2003. So if you go strictly by POSIX standards, you shouldn't rely on either.
Re:C String Creation by to3m on Thursday February 11, 2016 @09:03PM (#11084834)
You'd probably be able to duplicate open_memstream on OS X using funopen.
Re:C String Creation by btrask on Thursday February 11, 2016 @09:59PM (#11085023)
Ran into this recently. It's not open_memstream but same idea: https://github.com/NimbusKit/memorymapping