getopt errors

Johannes Pfau via D.gnu d.gnu at puremagic.com
Fri Jan 22 05:03:58 PST 2016


Am Fri, 22 Jan 2016 11:32:30 +0000
schrieb Sebastiaan Koppe <mail at skoppe.eu>:

> On Friday, 22 January 2016 at 10:06:01 UTC, Johannes Pfau wrote:
> > defaultGetoptPrinter is not yet available in the phobos version 
> > used by GDC. GDC uses phobos version 2.066, 
> > defaultGetoptPrinter was added in 2.067.  
> 
> Thanks. I never know which version of this supports which version 
> of that. Any easy way of checking this? I mean, how can I tell 
> that gdc 5.3.0-1 supports phobos 2.066?
> 

The best way is running this code snippet:
---------------------------------------------------
import std.compiler;
import std.stdio;

void main()
{
    writefln("%s %s %s.%s (D%s)", name, vendor,
        version_major,
        version_minor, D_major);
}
---------------------------------------------------
You can also have a look at the std.compiler implementation if you want
to use the __VERSION__ and __VENDOR__ variables directly.

> I reckon other people run into these errors as well, and it would 
> be nice if there was a way of checking whether a function is 
> supported in gdc/ldc x.x.x Hmm. Sounds like a nice project with 
> git, libdparse and vibe.

Yes, this is really a common problem. I'd say the simplest way to check
is trying to compile the code with the matching DMD version (e.g.
2.066.1).

> What about the other errors though?

Same reason. The old getopt code can't handle the help strings and
therefore produces these error messages. This works:

---------------------------------------------------
import std.getopt;
void main(string[] args)
{
	bool time;
	string fileIn;
	string fileOut;

	getopt(
		args,
		"time", &time,
		"i|input", &fileIn,
		"o|output", &fileOut
	);
}


More information about the D.gnu mailing list