Bugs item #2807075, was opened at 2009-06-16 11:54
Message generated for change (Tracker Item Submitted) made by luccat
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=462816&aid=2807075&group_id=51305

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxJSON
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Luciano Cattani (luccat)
Assigned to: Nobody/Anonymous (nobody)
Summary: [wxJSON v1.0] build fault on mingw

Initial Comment:

Hi,
I have to reopen bug ID 2735592 because after analizing it I came to the 
conclusion that it is actually a bug (although not related to wxJSON) that 
could be fixed somewhat.
The wxJSON library does not compile on mingw: Below is the compiler's errors:

/home/AndrejsC/wxJSON-1.0.0/_build_/bk-deps g++ -c -o wxjson_lib_jsonreader.o 
-I../include -I/mingw/include -D__WXMSW__ -mthreads -O2 ../src/jsonreader.cpp
In file included from ../include/wx/jsonreader.h:35, from 
../src/jsonreader.cpp:15:
../include/wx/jsonval.h:270: error: conflicting declaration 'typedef class
std::tr1::unordered_map<wxString, wxJSONValue, wxStringHash, wxStringEqual,
std::allocator<std::pair<const wxString, wxJSONValue> > > wxJSONInternalMap'
../include/wx/jsonval.h:40: error: 'struct wxJSONInternalMap' has a
previous declaration as 'struct wxJSONInternalMap'
../include/wx/jsonval.h:354: error: field 'm_valMap' has incomplete type
make: *** [wxjson_lib_jsonreader.o] Error 1


The problem seems to be that the 'wxHashMap' container class on mingw relies on 
the STL std::map template as the actual container but it behaves very strangly 
because it cause the redefinition of wxJSONInternalMap.
Consider the following code, actually used in wxJSON:

------------ EXAMPLE 1 -------------

// forward declaration
class wxJSONInternalMap;


class wxJSONValue
{
  ...
  // this is the reason of the forward declaration
  const wxJSONInternalMap* AsMap() const;
  ...
}
WX_DECLARE_STRING_HASH_MAP( wxJSONValue, wxJSONInternalMap );


-------- END EXAMPLE 1 -----------

The code compiles fine on my Linux machine and on Windows using BCC 5.5
Now substitute the wxWdiget's hashmap declaration with the following which uses 
STL:

typedef std::map<wxJSONValue>   wxJSONInternalMap;


Now the code is wrong and does NOT compile on my linux machine and the error 
message is the same as the one reported above when using mingw.
Also the code does NOT compile on windows BCC 5.5; the error message in this 
case is more accurate and it explicitly says that the wxJSONInternalMap was 
redefined as a different type (it is now a typedef).

The correct code, when using STL is the following:

------------ EXAMPLE 2 -------------

typedef std::map<class wxJSONValue>   wxJSONInternalMap;

class wxJSONValue
{
  ...
  const wxJSONInternalMap* AsMap() const;
  ...
}

-------- END EXAMPLE 2 -----------

This code DOES compile on both my systems.
The solution using STL is to use a forward declaration for wxJSONValue, next to 
write the container STL declaration and finally to define wxJSONValue but this 
solution is not applicable when using wxWidget's containers because the 
'wxHashMap' macro requires the wxJSONValue to be fully known when declaring the 
container.
The enclosed 'jsonval.h' header file contains a patched version of the 
wxJSONValue declaration which can be used on mingw. Andrejs had compiled it 
successfully.

The bug will be definitely fixed when version 1.1 will be released which adds 
an option that allows the use of STL as the container's classes for JSON arrays 
/ objects instead of wxWidget's own container classes.
I plan to release version 1.1 in july / august 2009.






----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=462816&aid=2807075&group_id=51305

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
wxCode-users mailing list
wxCode-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxcode-users

Reply via email to