PDA

View Full Version : GetFileSizeEx was not declared in this scope



Threepwood
8th February 2011, 10:23
Hi,

I use GetFileSizeEx since it seems to work faster than working with QFileInfo.

Now I wanted to use it inside a new class I added, and QT creator tells me "GetFileSizeEx was not declared in this scope".
I copied ALL header Files that are included in the class that works fine, but the problem still consist.

Other function calls like FindFirstFileW and CreateFileW wont raise an error.

Qt Creator even shows me the prototype of the function in a Tooltip "BOOL GetFileSizeEx(HANDLE, PLARGE_INTEGER)"

What am i doing wrong?

stampede
8th February 2011, 11:45
From <winbase.h>:

#if (_WIN32_WINNT >= 0x0500)
WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE,PLARGE_INTEGER);
#endif
Check which headers were included before <winbase.h> or <windows.h> when GetFileSizeEx was working, one of them could modify the _WIN32_WINNT define.

According to this article (http://msdn.microsoft.com/en-us/library/aa383745(v=vs.85).aspx#setting_winver_or__win32_wi nnt) you can do that yourself, just put this in your .cpp file ( the one where you are trying to call GetFileSizeEx ):


// 0x0501 is for Windows XP ( no service pack ),
// values for other configurations are listed in the article
#define _WIN32_WINNT 0x0501
#include <windows.h>

Threepwood
8th February 2011, 12:03
@stampede: You made my day :)

The order of the header files did the trick!

Works fine:


#include <QObject>
#include <QString>
#include <QStringList>

#include <qt_windows.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>



Throws ... not declared Error:


#include <qt_windows.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include <QObject>
#include <QString>
#include <QStringList>


I have never experienced such a strange behavior before.


Problem solved, thanks again!