digitalmars.D.bugs - [Issue 10674] New: getopt does not work for enum type
- d-bugmail puremagic.com (30/30) Jul 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10674
- d-bugmail puremagic.com (16/16) Jul 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10674
- d-bugmail puremagic.com (10/11) Jul 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10674
http://d.puremagic.com/issues/show_bug.cgi?id=10674 Summary: getopt does not work for enum type Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: ttanjo gmail.com In the document of std.getopt.getopt it recognizes enum types but the following code does not work in dmd v2.064-devel-de68798 on Linux 64bit. --- import std.getopt; void main() { auto args = ["--color=yes"]; // The following code is in the document of getopt enum Color { no, yes } Color color; // default initialized to Color.no getopt(args, "color", &color); assert(color == Color.yes); // failed! } --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 19 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10674 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |hsteoh quickfur.ath.cx Resolution| |INVALID The problem is that args[0] is expected to be the program name, so std.getopt does not try to parse it as an option. If you replace the declaration of args with this: auto args = ["program.exe", "--color=yes"]; then the code works as expected. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 19 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10674 Thank you for your comment. After fixing args, I confirmed it works as expected. BTW,The problem is that args[0] is expected to be the program name,is it described in the document? I did not find it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 19 2013