goblinhack/c-plus-plus-serializer

values arent read correctly

Opened this issue · 2 comments

Hi the values read arent working, on windows, visual studio:

std::cout << "save to " << filename << std::endl;
std::ofstream out(filename, std::ios::binary);
char                          a = 42;
unsigned short         b = 65535;
int                           c = 123456;
out << bits(c) << bits(b) << bits(c)  ;

is read:

a: char @
b: unsigned short : 482
c: int 1090518784

with read code :

    char                          a;
    unsigned short         b;
    int                           c;
    in >> bits(a) >> bits(b) >> bits(c)  ;
    std::cout << std::endl;
    std::cout << "read:" << std::endl;
    std::cout << "  a: char                     " << a << std::endl;
    std::cout << "  b: unsigned short           " << b << std::endl;
    std::cout << "  c: int                      " << c << std::endl;

    std::cout << std::endl;

It sounds like vis studio is picking up the incorrect template for short/int - the debug might help show which

another option is to try to enable USE_SIZE_T