trying to make as_int() return long long

Help
2011-08-23
2013-06-12
  • Hey,

    I'm trying to compile libjson with this option:

    #define JSON_INT_TYPE long long
    

    I'm using Visual Studio 2010 Express and get error c1017 in this line:

    #if (JSON_INT_TYPE == long long) && defined(JSON_ISO_STRICT)
    

    in file JSONDefs.h

    Of course I do not have JSON_ISO_STRICT defined.
    When I remove that check and just let the compiler define json_int_t as long long:

    typedef JSON_INT_TYPE json_int_t;
    

    I get more errors, because in JSONNode.h as_int is declared like this:

    long as_int(void) const json_nothrow json_read_priority;
    

    Having replaced that with

    json_int_t as_int(void) const json_nothrow json_read_priority;
    

    I can finally compile the library.

    Can I expect this to work correctly now with numbers bigger than what long can store?
    I'm going to test this now…

    Thanks
    Ralf

     
  • I see, that was an oversight, the JSONNode declaration should match the implementation, which uses json_int_t.  I will fix it and release a new version shortly.

    What error did VC++ give you for #if (JSON_INT_TYPE == long long) && defined(JSON_ISO_STRICT)?  That's perfectly valid C++ code.

     
  • Hmm, I was unaware of that limitation in the preprocessor, I will make that a g++ only error.