Me:
>> Be aware that if you need trailing [non-option] arguments, such as
>> filenames, that you need to put an explicit '--' in the command line.
>>
>> ./flApp [options handled by args()] -- file1 file2 file3 ...
>>
>> I always forget the '--', and then wonder why I get an error message
Ian:
> Huh?
>
> I've never done that... The "full" form of Fl::args(...) returns an
> int value that basically points at the first "non-option" parameter,
> then I just parse the filename (or whatever) directly by counting up
> through any remaining args...
>
> Dodgy pseudo-code:
>
> int used = Fl::args(...stuff...);
>
> if (used < argc) {
> // process reamining switches "by hand"
> for(int x = used; x < argc; x++)....
> }
>
> That kind of thing.
> Always *seems* to have worked OK for me, anyway.
You are quite right! Somehow the '--' is an idiom or workaround that
I needed at one point, and now keep on propagating it into the next project
needing args. It may be that handling '--' in my own options
parser meant that I didn't need to handle it explicitly in main().
I don't remember the reason for using it now :-(
It's not mentioned in http://www.fltk.org/doc-1.3/classFl.html but
there is a comment and test in Fl_arg.cxx:
// a word that does not start with '-', or a word after a '--', or
// the word '-' by itself all start the "non-switch arguments" to
// a program. Return 0 to indicate that we don't understand the
// word, but set a flag (return_i) so that args() will return at
// that point:
if (s[0] != '-' || s[1] == '-' || !s[1]) {return_i = 1; return 0;}
I leave deciding whether to use '--' as an exercise for the reader :-)
D.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk