viggox / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

Portability problem in uCLinux with GetInt function. #100

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. compile the sample program and library for uCLinux with cross compiler 
m68k-ucLinux-gcc  ( m68k-uclinux-tools) 

this is done for example : 
# /usr/local/m68k-uclinux-tools/bin/m68k-uclinux-g++  -o JSonClient-SPOTM3  
main.o -pipe -m5307 -static -Wl,-elf2flt='-s 8196' -Wl,-move-rodata

where main is the example provided bby rapidjason.

2. copy the binary JSonClient-SPOTM3 to the coldfire box with uCLinux.
3. run the binary

What is the expected output? What do you see instead?

Where Output in Linux/x86 platform is 
----------------------------------------
Original JSON:
  { "hello" : "world", "t" : true , "f" : false, "n": null, "i":123, "pi": 3.1416, "a":[1, 2, 3, 4] } 

Parsing in-situ with a buffer.

Parsing to document succeeded.

Access values in document:
hello = world
t = true
f = false
n = null
i = 123
pi = 3.1416
a[0] = 1
a[1] = 2
a[2] = 3
a[3] = 4

Modified JSON with reformatting:
{
    "hello": "rapidjson",
    "t": true,
    "f": false,
    "n": null,
    "i": 2432902008176640000,
    "pi": 3.1416,
    "a": [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        "Lua",
        "Mio"
    ],
    "author": "Milo Yip"
}

when running in uCLinux / coldfire platform 
----------------------------------------------

Original JSON:
  { "hello" : "world", "t" : true , "f" : false, "n": null, "i":123, "pi": 3.1416, "a":[1, 2, 3, 4] } 

Parsing in-situ with a buffer.

Parsing to document succeeded.

Access values in document:
hello = world
t = true
f = false
n = null
i = 0
pi = 3.1416
a[0] = 0
a[1] = 0
a[2] = 0
a[3] = 0

Modified JSON with reformatting:
{
    "hello": "rapidjson",
    "t": true,
    "f": false,
    "n": null,
    "i": 2432902008176640000,
    "pi": 3.1416,
    "a": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        "Lua",
        "Mio"
    ],
    "author": "Milo Yip"
}

What version of the product are you using? On what operating system?

Version is 0.11 and running in uCLinux in a coldfire processor.

Please provide any additional information below.

You can get the compiler from 
http://www.codesourcery.com/downloads/public/gnu_toolchain/m68k-uclinux/freescal
e-coldfire-4.3-209-m68k-uclinux.bin

Note: As a surprise this works on linux and when compiling for ARM processor 
with the crosscompiler  /opt/arm/2012.09-64/bin/arm-none-linux-gnueabi-g++ from 
CodeSourcery

wget 
http://www.codesourcery.com/downloads/public/gnu_toolchain/arm-none-linux-gnueab
i/arm-2009q3-67-arm-none-linux-gnueabi.bin

Original issue reported on code.google.com by salt1...@gmail.com on 14 Feb 2014 at 3:28

GoogleCodeExporter commented 8 years ago
Notice that the problem is that all GetInt() functions return cero ( 0) as 
value when doing printf ( ) or when using PrettyWritter

Original comment by salt1...@gmail.com on 14 Feb 2014 at 3:33

GoogleCodeExporter commented 8 years ago
I would suspect this to be an endianness problem.

Rapidjson tries to detect the endianness of the target processor via the 
'__BYTE_ORDER__' macro usually provided by GCC compilers and falls back to 
little endian by default.  Little endian would be wrong for m68k.

Does it help to compile with '-DRAPIDJSON_ENDIAN=RAPIDJSON_BIGENDIAN'?

Original comment by philipp....@gmail.com on 16 Feb 2014 at 11:54