Problem parsing IPv4/IPv6 addresses with std.socket.parseAddress

Dsciple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 27 07:39:10 PDT 2016


On Tuesday, 27 September 2016 at 14:02:25 UTC, Marc Schütz wrote:
> On Tuesday, 27 September 2016 at 09:04:53 UTC, Dsciple wrote:
>> As said, this works fine when tested in isolation, and the 
>> compiler only complains when using BindAddress as a member of 
>> ConfigParams.
>> Any idea what the problem may be?
>> Or is there maybe a ready to use, high-level library for 
>> parsing parameters from command-line arguments and config 
>> files of some kind?
>
> I assume your ConfigParams variable is global or static? Can 
> you show how you initialize it, and how it's declared?
>
> You're probably using it in a way that requires it to be 
> evaluated at compile time. That's the case for initializers of 
> global/static variables, as well as default values of struct 
> members.

Yes I think so.
I use static default values for all members of ConfigParams and I 
instantiate ConfigParams in my unit tests, so I assume that the 
variable would be global there.
The code looks like:

unittest {

   string[] args = [
     "binaryFileName",
     "--bindAddresses=0.1.2.3;4.5.6.7",
     "--bindHTTPPort=80",
     "--bindHTTPSPort=443",
     "--configFile=testfiles/test.conf.sdl",
     "--verbosityLevel=detailed",
   ];

   ConfigParams configParams;  // default values for parameters
   configParams.readFromAll(args); // values read from 
command-line arguents

   // assertion checks here
}

What do you suggest? Should I move all default initializations to 
a constructor?
Thank you for your response.



More information about the Digitalmars-d-learn mailing list