In Linux(ubuntu) fpos_t is in a struct
typedef fpos_t {
size_t _pos,
size_t _state
}
In Windows, fpos_t is not defined. In the code base, it is defined in this way.
#ifndef _FPOS_T_DEFINED
typedef __int64 fpos_t;
#define _FPOS_T_DEFINED
#endif /* _FPOS_T_DEFINED */
However, in my code
foo () {
fpos_t fsize;
fgetpos(fp, &fsize); // Function A
bar.len = (unsigned int)fsize; // for windows Function B
bar.body = (char *)SAFE_MALLOC( (size_t)fsize); // for windows
//bar.len = (unsigned int)fsize._pos; // for linux Function B
//bar.body = (char *)SAFE_MALLOC( (size_t)fsize._pos);// for linux
}
Question is what is the elegant way to substitute the fsize._pos to fsize when compiled in different platform. Method I knew
#if defined(LINUX)
//code for linux
#else
//code for windows
#endif