Rootcint and wchar mac os x

Hi all.

I’m trying to add some code to my project that uses the wchar and wstring types. However, it doesn’t play nice with rootcint. I get the following error

/Users/adam/softwareDev/root/v5.28.00c/bin/rootcint -f kdatabase/kdatabase_Dict.C -c -Iinclude -I./era kdatabase/KCouchDB.h kdatabase/KCurl.h kdatabase/KJson.h kdatabase/JSON.h kdatabase/JSONValue.h
Error: class,struct,union or type __signed not defined /usr/include/i386/_types.h:37:
Error: Missing whitespace at or after line 180.
Error: Unexpected end of file (G__fgetspace():2) /usr/include/_wctype.h:186:
Report: Unrecognized string ‘__END_DECLS’ ignored /usr/include/_wctype.h:187:
Error: Missing one of ‘{’ expected at or after line 132.
Error: Unexpected end of file (G__fignorestream():3) /usr/include/wctype.h:144:
Error: Missing one of ‘{’ expected at or after line 123.
Error: Unexpected end of file (G__fignorestream():3) /usr/include/wchar.h:218:
Error: class,struct,union or type wstring not defined prec_stl/functional:30:
Error: class,struct,union or type wstring not defined prec_stl/functional:31:
Error: Symbol wstring first is not defined in current scope prec_stl/utility:18:
Error: class,struct,union or type wstring not defined prec_stl/map:65:
Error: Symbol wstring first is not defined in current scope prec_stl/utility:18:
Error: Symbol wstring string_value is not defined in current scope kdatabase/JSONValue.h:75:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation

The JSON.h and JSONValues.h files are where the wstring type is used.

Any ideas?

thanks,
Adam

So, I found in another thread that ROOT doesn’t yet support wchar_t and wstrings.

What I did was to take my JSON and JSONValues classes (which I copied from mjpa.co.uk/blog/view/A-simple-C-JSON-library/) and removed the wchar_t and wstrings parts. (they are attached).

Now, when I run
/Users/adam/softwareDev/root/v5.28.00c/bin/rootcint -f kdatabase/kdatabase_Dict.C -c -Iinclude -I./era kdatabase/KCouchDB.h kdatabase/KCurl.h kdatabase/KJson.h kdatabase/JSON.h kdatabase/JSONValue.h

this works fine, but kdatabase_Dict.C doesn’t compile.

I get the error:

g++ -m64 -pipe -Wshadow -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Iinclude -I/Users/adam/softwareDev/root/v5.28.00c/include -I. -I./era -o kdatabase/kdatabase_Dict.o -c kdatabase/kdatabase_Dict.C
kdatabase/kdatabase_Dict.C: In member function ‘virtual void JSONValue::Streamer(TBuffer&)’:
kdatabase/kdatabase_Dict.C:543: error: invalid use of incomplete type ‘struct TVirtualStreamerInfo’
/Users/adam/softwareDev/root/v5.28.00c/include/TBuffer.h:28: error: forward declaration of ‘struct TVirtualStreamerInfo’
kdatabase/kdatabase_Dict.C:568: error: invalid use of incomplete type ‘struct TVirtualStreamerInfo’
/Users/adam/softwareDev/root/v5.28.00c/include/TBuffer.h:28: error: forward declaration of ‘struct TVirtualStreamerInfo’

Any help would be appreciated – I’m trying to find a good simple JSON parser for c++/ROOT that I can just drop into my project without having to require a 3rd party installation.

thanks,
Adam
kdatabase_Dict.h (2.86 KB)
kdatabase_Dict.C (102 KB)
JSON.h (2.71 KB)
JSON.cxx (6.7 KB)

Hi,

You need to request the new I/O style streamer for your classes.
Either write a LinkDef.h file that will specify it (with the trailing +):#pragma link C++ class JSONValue+; or by adding a trailing + after each header file:rootcint -f kdatabase/kdatabase_Dict.C -c -Iinclude -I./era kdatabase/KCouchDB.h+ kdatabase/KCurl.h+ kdatabase/KJson.h+ kdatabase/JSON.h+ kdatabase/JSONValue.h+

Cheers,
Philippe.

Hi Philippe

Thanks for your response.

So… I’m currently writing to disk a bunch of data using, apparently, the old I/O streaming method (no “+” in my call to rootcint). Will there be a problem if I switch to the new I/O streaming? Will I be able to read the old files with my library classes that use the ‘new’ I/O streaming?

cheers,
Adam

Hi,

See the User’s Chapter on I/O for the few potential pitfalls. At the very least, if you are giving your classes a ClassDef, you should increment the class version.

Cheers,
Philippe.

Thanks a lot Philippe… again.

So, why does the old style I/O streamer still even exist? From what I understand, this is root version < 3.0! Wasn’t version 3.0 released over a hundred years ago?

Adam

Hi Adam,

Since in some cases (STL collections for example) the layout on file is different, we need to keep the I/O code for backward compatibility reasons and can not really change the default either (because it would make the user code unable to read older ROOT files without any warnings).

Cheers,
Philippe.