<div dir="ltr">I think we need two more functions:<div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">        // at most one option from a set</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">        void G_option_exclusive(void *first, ...);</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">        // at least one option from a set</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">        void G_option_required(void *first, ...);</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">        // if the first option is present, at least one of the other</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">        //  options must also be present</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">        void G_option_requires(void *first, ...);</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">        // if the first option is present, all the other options must also be present.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">        // same as multiple G_option_requires(first, opt)...</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">        void G_option_requires_all(void *first, ...);</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">        // G_option_requires_all() doesn't make the second/third... option require all the other options.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">        // if any option is present, all the other options must also be present.</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">        // all or nothing from a set</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">        void G_option_inclusive(void *first, ...);</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 11, 2014 at 10:12 AM, Huidae Cho <span dir="ltr"><<a href="mailto:grass4u@gmail.com" target="_blank">grass4u@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Right, G_option_exclusive(void *first, ...) should work.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Jun 11, 2014 at 6:43 AM, Glynn Clements <span dir="ltr"><<a href="mailto:glynn@gclements.plus.com" target="_blank">glynn@gclements.plus.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br>
Huidae Cho wrote:<br>
<br>
> Maybe, we can use variadic macros in C99 to remove the first name argument.<br>
<br>
</div>GRASS doesn't require C99. In general, we try to keep the hard<br>
dependencies to a bare minimium, particularly in core functionality<br>
such as libgis.<br>
<br>
In any case, the <stdarg.h> requirement for an explicit first argument<br>
isn't a significant problem. The functions would never be called with<br>
less than two arguments.<br>
<br>
In the worst case, it complicates the implementation slightly, as we<br>
can't simply iterate over all of the arguments using va_arg(), but<br>
have to treat the explicit argument separately. That can be handled<br>
like:<br>
<br>
        void G_option_exclusive(void *first, ...)<br>
        {<br>
            void *opt = first;<br>
            va_start(ap, first);<br>
            for (;;) {<br>
                process(opt);   // search for opt in options/flags<br>
                opt = va_arg(ap, void*);<br>
                if (!opt)       // NULL terminator<br>
                    break;<br>
            }<br>
            va_end(ap);<br>
        }<br>
<span><font color="#888888"><br>
--<br>
Glynn Clements <<a href="mailto:glynn@gclements.plus.com" target="_blank">glynn@gclements.plus.com</a>><br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>