getOpt with shared
Danny Arends
Danny.Arends at gmail.com
Fri May 11 17:25:44 UTC 2018
Hey all,
I have been working on creating a multi-threaded application, so
I have a shared configuration object which hold several command
line parameters (which I fill using getopt).
The problem is that I get deprecation warnings when trying to set
numerical values:
/usr/include/dmd/phobos/std/getopt.d(895,36): Deprecation:
read-modify-write operations are not allowed for shared
variables. Use core.atomic.atomicOp!"+="(*receiver, 1) instead.
using getopt with a shared object and boolean values seems
completely broken:
/usr/include/dmd/phobos/std/getopt.d(895,34): Error: operation
not allowed on bool *receiver += 1
/usr/include/dmd/phobos/std/getopt.d(751,46): Error: template
instance `std.getopt.handleOption!(shared(bool)*)` error
instantiating
/usr/include/dmd/phobos/std/getopt.d(435,15): 6 recursive
instantiations from here: getoptImpl!(string, shared(string)*,
string, shared(string)*, string, shared(VSync)*, string,
shared(ulong)*, string, shared(bool)*, string, shared(Verbose)*)
Is getopt not supposed to be used with shared structs ?
More information about the Digitalmars-d-learn
mailing list