Cross platform coding: data type issues to remember.

1. long data type.
Always remember on Windows long is 4 bytes in size. On Linux it is 8 bytes!

2. Reading unsigned short variable.

void foo(char *shortString)
    unsigned short val;
    sscanf(shortString, "%u", &val);

This code works properly on Ubuntu. But gives core dump on CentOS / RHEL.
Never read a short variable using “%d” or “%u”, always use “%h” or “%hu”

    // this is the right thing to do.
    sscanf(shortString, "%hu", &val);