I'm trying to use wxnim and met a problem.
All the widget's getValue method returns a WxString, by reading the document, WxString.cStr().asCString() could return a const char *.
So I tried to receive the string value using
var str = textCtrl.getValue().cStr().asCString()
Compiler tells initialize a variable of type 'NCSTRING' (aka 'char *') with an rvalue of type 'const char *'.
How can I convert const char * from C++ side to nim string?
No, $ dosen't work.
Both ` var name = $(nameCtrl.getValue().cStr().asCString())` and var name = $nameCtrl.getValue().cStr().asCString() reports same error.
error: cannot initialize a variable of type 'NCSTRING' (aka 'char *') with an rvalue of type 'const char *'
I hit the same problem a long time ago. IIRC, I had to do this:
let
cstr = foo.asCstring()
nimstr = $cstr
I never learned why $() didn't work, but sometimes the parser has trouble. Not too big a deal.