On 07/23/2013 04:01 PM, Daniel Santos wrote: > On 07/23/2013 04:24 PM, Daniel Santos wrote: >> On 07/23/2013 10:55 AM, Bernhard Voelker wrote: >>> Is there already something available in gnulib like >>> err_exclusive_options() in util-linux [1] to automatically >>> catch mutual exclusiveness of options inside the getopt loop? >>
> Well, it does seem possible indeed, but I haven't figured out a way to > get gcc to unroll a loop the way I need it to so that I can avoid using > static offsets. Short of doing so, the compile-time check would require > repetitive code that supplies static offsets. Here is an example that > will detect a dupe for up to 8 characters. I don't think you are solving the same question as posed by the OP. It is not a question of whether there are duplicate short-option letters in the option string passed to getopt() (a compile-time value), but whether there are conflicting options, from mutually exclusive groups, passed in by the user at runtime. getopt_long() doesn't even have a way to mark up mutually-exclusive options. It seems to me that argp allows for a bit more fancy layouts in option parsing, but as far as I know, anyone using getopt and wanting to enforce mutual exclusion between particular options has had to do it by hand. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature