Results 1 to 3 of 3

Thread: GetFileSizeEx was not declared in this scope

  1. #1
    Join Date
    May 2010
    Posts
    5
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default GetFileSizeEx was not declared in this scope

    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?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: GetFileSizeEx was not declared in this scope

    From <winbase.h>:
    Qt Code:
    1. #if (_WIN32_WINNT >= 0x0500)
    2. WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE,PLARGE_INTEGER);
    3. #endif
    To copy to clipboard, switch view to plain text mode 
    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 you can do that yourself, just put this in your .cpp file ( the one where you are trying to call GetFileSizeEx ):
    Qt Code:
    1. // 0x0501 is for Windows XP ( no service pack ),
    2. // values for other configurations are listed in the article
    3. #define _WIN32_WINNT 0x0501
    4. #include <windows.h>
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to stampede for this useful post:

    Threepwood (8th February 2011)

  4. #3
    Join Date
    May 2010
    Posts
    5
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: GetFileSizeEx was not declared in this scope

    @stampede: You made my day

    The order of the header files did the trick!

    Works fine:
    Qt Code:
    1. #include <QObject>
    2. #include <QString>
    3. #include <QStringList>
    4.  
    5. #include <qt_windows.h>
    6. #include <sys/types.h>
    7. #include <sys/stat.h>
    8. #include <io.h>
    9. #include <stdio.h>
    10. #include <stdlib.h>
    11. #include <errno.h>
    To copy to clipboard, switch view to plain text mode 


    Throws ... not declared Error:
    Qt Code:
    1. #include <qt_windows.h>
    2. #include <sys/types.h>
    3. #include <sys/stat.h>
    4. #include <io.h>
    5. #include <stdio.h>
    6. #include <stdlib.h>
    7. #include <errno.h>
    8.  
    9. #include <QObject>
    10. #include <QString>
    11. #include <QStringList>
    To copy to clipboard, switch view to plain text mode 

    I have never experienced such a strange behavior before.


    Problem solved, thanks again!

Similar Threads

  1. Variable not declared in this scope error
    By hojoff79 in forum Newbie
    Replies: 1
    Last Post: 30th December 2010, 00:29
  2. Replies: 10
    Last Post: 22nd September 2010, 06:20
  3. `lineEdit' was not declared in this scope?
    By i4ba1 in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2009, 14:36
  4. QDomDocument was not declared in this scope
    By grantbj74 in forum Newbie
    Replies: 5
    Last Post: 25th August 2009, 09:43
  5. Replies: 2
    Last Post: 28th December 2007, 18:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.