Results 1 to 14 of 14

Thread: Conflicting header definitions

  1. #1
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Conflicting header definitions

    I use the QT SDK 4.5.1 in WindowsXP sp3 and work in QT Creator 1.1.0.

    I have to use WinDDK to retrive USB flash disk information. My application has to include three files:
    #include <windows.h>
    #include <winioctl.h>
    #include <ddk/ntddstor.h>

    While building, I get a lot of double definitions as following:

    In file included from main.cpp:20:
    D:/Qt/2009.02/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/ddk/ntddstor.h:299: error: redefinition of `struct _STORAGE_DEVICE_NUMBER'
    D:/Qt/2009.02/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/winioctl.h:523: error: previous definition of `struct _STORAGE_DEVICE_NUMBER'
    D:/Qt/2009.02/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/ddk/ntddstor.h:303: error: conflicting declaration 'typedef int STORAGE_DEVICE_NUMBER'
    D:/Qt/2009.02/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/winioctl.h:527: error: 'STORAGE_DEVICE_NUMBER' has a previous declaration as `typedef struct _STORAGE_DEVICE_NUMBER STORAGE_DEVICE_NUMBER'
    D:/Qt/2009.02/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/ddk/ntddstor.h:303: error: declaration of `typedef int STORAGE_DEVICE_NUMBER'


    Please give me some advices to work around this issue.

    Many thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Conflicting header definitions

    ...and where is the connection to Qt?

  3. #3
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Conflicting header definitions

    Thanks for your quick reply.

    I am working in QT Creator 1.1.0. The code is built in QT and I think MINGW is compiler.

    Could you please give me some advices?

    Many thanks in advance.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Conflicting header definitions

    MinGW has nothing to do with Qt. Different things. Your problems has only to do with WinDDK what ever that is. According to your error messages: Do you need all of that header files? They are conflicting each other...

  5. #5
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Conflicting header definitions

    Could you please suggest where my post should be to get some advices?
    If you know how to retrieve USB stick without using WinDDK in QT please help me.
    Last edited by jacky; 3rd May 2009 at 18:10.

  6. #6
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Conflicting header definitions

    The WinDDK is the "Windows Device Driver Kit".
    Maybe deleting one of the include lines of winioctl.h or ntddstor.h might help?

  7. #7
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Conflicting header definitions

    My application is based on QT. What I have to do is to retrieve the Removable Disks (USB stick) information
    I think I should post my fragment of code that causes the issue here

    Qt Code:
    1. HANDLE hDisk;
    2. DISK_GEOMETRY diskGeometry;
    3. DWORD dwBytes;
    4.  
    5. for (int i = 0; i < 255; i ++)
    6. {
    7. wchar_t str[18];
    8. swprintf (str, L"\\\\.\\PhysicalDrive%d", i);
    9. hDisk = CreateFile(str, MAXIMUM_ALLOWED, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL);
    10. if (hDisk != INVALID_HANDLE_VALUE)
    11. {
    12. DeviceIoControl(hDisk, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &diskGeometry, sizeof (DISK_GEOMETRY), &dwBytes, NULL);
    13. // Only proceed if disk is a removable media
    14. if (diskGeometry.MediaType == RemovableMedia)
    15. {
    16. // Display disk information ....
    17.  
    18. // TODO: Display USB reader information
    19. }
    20. }
    21. }
    To copy to clipboard, switch view to plain text mode 


    Many thanks in advacne.

  8. #8
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Conflicting header definitions

    The WinDDK is the "Windows Device Driver Kit".
    Maybe deleting one of the include lines of winioctl.h or ntddstor.h might help?
    Thanks for your advice. This may help in case of less code.

    That code fragment is a small sample one. I think it is infeasible when the code has to add more and include more files such as
    #include <ddk/cfgmgr32.h>

  9. #9
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Conflicting header definitions

    So it seems that we can blame MS for ugly header files, where the same struct is defined in different headers .

    Perhaps you can separate the code in different modules.
    One module includes (beside other headers if necessary ) winioctl.h, the other modules includes ntddstor.h.

  10. #10
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Conflicting header definitions

    I just want to notice that your problem (even if your app is made with a lot of Qt classes) i connected only with Win API and DDK and whatever... but your problem is not connected qith Qt at all - so the better place for your post is in some Windows forum, or you can search for some info at http://msdn.com.

    And now few words about your error: it says that there is struct _STORAGE_DEVICE_NUMBER which is defined twice: first time in one header (ntddstor.h) and second time in second header (winioctl.h). So maybe you just don't need those both headers and one should be enough?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  11. #11
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Conflicting header definitions

    Many thank Boron and faldżip for your suggestions.

    I post this issue here in hope to find someone, who met this issue, to give me some advices to work around this. And this also helps other QT developers who will meet this issue to solve it faster in future. I doesn't post here to blame anyone who produced those ugly header files.

    I am newbie in QT but I have 10+ years using Microsoft VC++ so that I am so sure that these DDK header files produced by MINGW not by Microsoft.

    Perhaps you can separate the code in different modules.
    One module includes (beside other headers if necessary ) winioctl.h, the other modules includes ntddstor.h.
    The issue happens again when I combine two modules into one application.

    And now few words about your error: it says that there is struct _STORAGE_DEVICE_NUMBER which is defined twice: first time in one header (ntddstor.h) and second time in second header (winioctl.h). So maybe you just don't need those both headers and one should be enough?
    It is a long list of "defined twice" like this and I only posted here a few one as a sample so it must take a lot of time to remove them. And I am not sure that my application will work fine without crash if I manually remove them. Please tell me how you think about this case.

    Many thanks again for your advices. I am still looking around to find someone who got the same issue to help me.
    Last edited by jacky; 4th May 2009 at 03:05.

  12. #12
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Conflicting header definitions

    I see many people asking what my question has to do with QT. The problem is that I use QT for an application which has to run on Macintosh, Windows and Linux and it must be able to read a USB. Original it was a Windows VC++ application and I want to get rid of that completely hence I started to redo all in QT. Many users still use the original application and therefore we have to be able to have the QT version to run on Windows as well.

    If any person here can advise how I can read the USB information (Serial number, provider, other information) I would very much appreciate it.

  13. #13
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Conflicting header definitions

    I see many people asking what my question has to do with QT. The problem is that I use QT for an application which has to run on Macintosh, Windows and Linux and it must be able to read a USB. Original it was a Windows VC++ application and I want to get rid of that completely hence I started to redo all in QT. Many users still use the original application and therefore we have to be able to have the QT version to run on Windows as well.
    OK, but your question at the beginning is about how to make those specific Win32 headers and functions work. And it is independent of use of Qt.
    If any person here can advise how I can read the USB information (Serial number, provider, other information) I would very much appreciate it.
    Try looking for libusb and/or LibUsb-Win32.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  14. #14
    Join Date
    Apr 2009
    Posts
    15
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Conflicting header definitions

    I have just taken a look at libusb, it is not implemented for Windows because I see there is a <poll.h> include in the core.c file. Do you know how to work around it in Windows?

    I will take a look at LibUsb-Win32 to see if it helps.

    I will ask you when I get stuck.

    Many thanks for your help.

Similar Threads

  1. How to edit Horizontal Header Item in QTableWidget
    By ioannis in forum Qt Programming
    Replies: 6
    Last Post: 5th March 2013, 18:50
  2. QTableWidget NW corner header item?
    By McKee in forum Qt Programming
    Replies: 9
    Last Post: 30th May 2012, 23:44
  3. Howto : Header and Footers
    By pshah.mumbai in forum Qt Programming
    Replies: 0
    Last Post: 29th October 2008, 15:32
  4. How to customize horizontal header (diagonal header view)
    By vairamuthu.g in forum Qt Programming
    Replies: 4
    Last Post: 4th September 2008, 15:59
  5. Replies: 0
    Last Post: 10th November 2006, 13:46

Tags for this Thread

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.