When upgrading another program to 64 bit I ran into this -
strlen() in 32 bit returns size_t which seems to be DWORD
Yes because a DWORD can cover a string long the whole addressing space 32bits => 4Gb.
strlen() in 64 bit returns size_t which seems to be unsigned long long int
Once again address whole memory 64bits => 16 exibytes (18'446'744'073'709'551'616 bytes)
so far so good - however in fileapi.h the WriteFile function
WINBASEAPI BOOL WINAPI WriteFile(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED);
doesn't change parm 3 so when compiling for 64 bits you get
Log_To_File.c(101): warning #2215: Conversion from 'unsigned long long int' to 'unsigned long int'; possible loss of data or unexpected result.
Yes there could be a loss of data if your record is bigger than 4Gb. Indeed you need to write so much data?
The only way I can see is either suppress the #2215 warning or cast (DWORD)strlen()
The cast doesn't harm in 32 or 64bits. Unless you have to write more than 4Gb in one write...
Doesn't seem to be a WriteFile64 .... and WriteFile is not marked as depreciated..
Thoughts?
Probably if you need to transfer such big amount of data, an operation that will take time anyway despite how fast is your disk, you'll not use this simple technique. So don't seems to be a really need for
WriteFile64...
To keep contained buffers extensions and manage the update of transfer data more appropriately you'll use an asynchronous transfer, overlapped, to keep running code and updating transfer buffers on the fly.
Do you really need to transfer more than 4Gb at once?