problem with args

Christian Kamm kamm.incasoftware at shift-at-left-and-remove-this.de
Sat Sep 15 02:03:01 PDT 2007


Chris Paterson wrote:

> int main(char[][] args)
> {
>  if (args.length > 0) {
>   const int max = std.conv.toInt(args[1]);
>   writefln("max=%d", max);
>  }
>  return 0;
> }

const in D 1.0 means compile time constant and neither args[1] nor the call
to toInt can be evaluated at compile time. Remove the const and it will
compile. Also change the check to args.length > 1 though.

It's the same for 2.0 at the moment, I think. Probably you could use final
there to get the effect you desired, but final might be removed in the
future.

Remember to use the digitalmars.D.learn newsgroup for questions like this.

Cheers,
Christian



More information about the Digitalmars-d mailing list