c++ - size of off_t at compilation time -


after reading numerous report on stackoverflow, decide go file* (over std::fstream) manipulate binary files. furthermore, needed truncate file during process (_chsize or ftruncate), work file descriptor (fileno call).

so trying have working (c++):

#define _file_offset_bits 64 #include <stdio.h> static inline off_t ftello(file *stream) { #if _win32 #if defined(__mingw32__)   return ftell( stream ); // 32bits #else   return _ftelli64( stream ); #endif #else   return ftello( stream ); #endif } 

however not working on visual studio. not find anywhere in documentation way change size of off_t @ compilation time.

it tempting have signature (i assume have c99: stdint.h):

static inline int64_t ftello(file *stream) 

what others have been doing ?

for reference, here have been reading, seems indicate file* provide better performance:

if enforcing large file support, define ftello() return int64_t.

you might find inttypes.h more portable stdint.h though.

ms not famous being compatible unix, though provide named functions. if going provide compatibility layer, better existing layers (e.g. boost.filesystem), there subtleties everywhere.

by way, boost.filesystem has resize_file().


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -