dropbox / json11

A tiny JSON library for C++11.
MIT License
2.54k stars 613 forks source link

swig4.0.0 and mingw compile the test.cpp(main modified to be a function) :error: 'final' is not a member of 'json11' #139

Closed kematy closed 5 years ago

kematy commented 5 years ago

when I use swig4.0.0 and mingw compiling the test.cpp(main modified to be a function) ,I encounted the error: 'final' is not a member of 'json11'.....How shoud I do?

drw_wrap.cxx: In function 'VALUE _wrap_json11_final_get(VALUE)': drw_wrap.cxx:46293:54: error: 'final' is not a member of 'json11' _val = SWIG_NewPointerObj(SWIG_as_voidptr(&json11::final), SWIGTYPE_p_Json, 0 ); ^ drw_wrap.cxx:1380:81: note: in definition of macro 'SWIG_NewPointerObj'

define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags)

                                                                             ^~~

drw_wrap.cxx:46293:29: note: in expansion of macro 'SWIG_as_voidptr' _val = SWIG_NewPointerObj(SWIG_as_voidptr(&json11::final), SWIGTYPE_p_Json, 0 ); ^ drw_wrap.cxx: In function 'VALUE _wrap_json11_final_set(VALUE, VALUE)': drw_wrap.cxx:46309:15: error: 'final' is not a member of 'json11' json11::final = (reinterpret_cast< Json >(argp)); ^~~~~ drw_wrap.cxx:46309:43: error: 'Json' does not name a type; did you mean 'sin'? json11::final = (reinterpret_cast< Json >(argp)); ^~~~ sin drw_wrap.cxx:46309:48: error: expected '>' before '' token json11::final = (reinterpret_cast< Json >(argp)); ^ drw_wrap.cxx:46309:48: error: expected '(' before '' token drw_wrap.cxx:46309:50: error: expected primary-expression before '>' token json11::final = (reinterpret_cast< Json >(argp)); ^ drw_wrap.cxx:46309:58: error: expected ')' before ';' token json11::final = (reinterpret_cast< Json >(argp));

kematy commented 5 years ago

I have no problem compiling with mingw alone. The problem seems to be with swig. I don't know how to configure swig's.i interface file

kematy commented 5 years ago

in json11.hpp :class Json final { public: .....} Maybe the swig wrapper can't deal with class Json final,I am a beginer and I don't know how to modify the code

j4cbo commented 5 years ago

I would not expect swig to be able to produce meaningful bindings for json11 automatically. You may want to use a json library that is native to whatever language you're using swig to bind to.