Now this is not a problem, but it may be in the future, depending on where you will transfer the application. This is because size_t is defined as large enough to hold pointer offsets, so if you have a 64-bit pointer, size_t will also be 64 bits. Now, long ones may or may not be 64 bits, because size rules for basic types in C / C ++ give place to some changes.
But if you want to write these values ββto a file, you still have to choose a specific size, so there is no other option than converting to long (or long if necessary). Even better, use one of the new types, such as int32_t.
My advice: somewhere in the header of your file, store sizeof for the type in which you converted size_t. By doing this, if in the future you decide to use a larger one, you can still maintain the old size. And for the current version of the program, you can check whether the size is supported or not, and give an error if not.
Fabio ceconello
source share