From: Tor L. <tm...@ik...> - 2009-02-06 20:52:09
|
> I've this compiler defines (like in linux) > -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 What makes you think these defines would have any effect on MinGW? The initial underscore should tell you that that these identifiers are platform-dependent. ... and if you are going to say "but MinGW is supposed to make programming on Windows be like on Linux", sorry, you are wrong. Why don't you show us a complete and minimal sample program that behaves oddly in your opinion? For example, the program below works fine for me on Vista. No -D options necessary when compiling. (Note that the DeviceIoControl call is there just so that the file is set to be sparse (like files on Unixes). Otherwise running this program will take ages and it most likely fills your disk as it would create a file that occupies 1.2 TB... #include <windows.h> #include <winioctl.h> #include <stdio.h> #include <io.h> #define ALOT 1234*1024*1024*1024LL int main (int argc, char **argv) { FILE *f = fopen ("foo.bar", "wb"); char bfr[5]; DWORD bytes_returned; if (!DeviceIoControl ((HANDLE) _get_osfhandle (fileno (f)), FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &bytes_returned, NULL)) fprintf (stderr, "Could not set file sparse\n"), exit (1); fseeko64 (f, ALOT, 0); printf ("We are now at file offset %I64d\n", ftello64 (f)); fprintf (f, "Hello there"); printf ("And now at %I64d\n", ftello64 (f)); fflush (f); fclose (f); fopen ("foo.bar", "rb"); printf ("Seeking there again\n"); fseeko64 (f, ALOT, 0); printf ("We are now at file offset %I64d\n", ftello64 (f)); printf ("Read %d bytes\n", fread (bfr, 1, 5, f)); printf ("\"%.5s\"\n", bfr); return 0; } --tml |