Don't use long. It has different size depending on arch. Use int64_t to be sure.