28 Sep 2005
(updated 28 Sep 2005 at 05:49 UTC) »
Argument parsing libraries, continued
Results from my informal poll:
1. haruspex recommended using getopt. Yes, there is a Microsoft-friendly version of this routine (they actually recommend using it in lieu of argp in one of their lame Unix->Win32 porting guides).. but it really only provides a small subset of the functionality of argp / popt (e.g.: you can't use it to automagically generate help messages).
2. Jim Morrison (ex-Nitiite and free software hacker extraordinaire) pointed out that argp was, in fact, not part of glibc. It's part of a stand-alone library called gnulib. The idea here is to provide a set of tiny standalone routines that you can compile into your own program and library as needed. This sounded promising, so I played with it a little bit this evening.
Sigh. Their version of argp depends on something like 10 other gnulib modules, few of which compile out of the box on Windows (they expect a certain amount of unixism in your environment). End result is that I'd need to hack this up quite a bit-- and I'm not sure if the end result would be much better than including popt in the WvStreams distribution. The gains of a cleaner API and a "guaranteed" future seem rather marginal compared to the extra effort involved in making this thing work properly (not to mention the bloat of a huge number of otherwise unnecessary functions). If it compiled out of the box, it would be a different story.
(yes, it would be a worthwhile project to do a full port of gnulib to MSVC.. but that's frankly not a project I'm particularly interested in).
3. Fridrich Strba pointed out that Tor Lilqvist has put up a Win32-friendly version of popt
I'm not sure how comfortable I am on relying on this as an external dependancy. Only libgnome uses it, and I understand that will be going away in the near future.
My conclusion is that statically including popt is probably the best option (which isn't really that horrible at the end of the day). I sure hope this pedantry was useful to someone.
apenwarr: You might want to go into more detail, since I doubt the average advogatan has much insight into NITI's internal development processes. :) The difference between specification and design wouldn't have been obvious to me a few years ago.
bwh: That's a very interesting, under-engineered approach to interoperability (I mean that in a good way).
The fact that it worked out so well for you likely has much to do with the fact that SVG has become such an ubiquitous format for vector graphics. To contrast, there is no real "hub" format for word processors so you really do need to write implementation-specific importers/exporters to get the best results. Maybe OpenDocument will change this, but I'm skeptical.
libwpd's "translation format" is actually a superset of what OpenOffice and Abiword provide. It has a richer model for lists than AbiWord and expresses more semantic content for page spans than OpenOffice.