Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt 5.12.0 MSVC 2017 32 Bit



  • My program was previously able to compile using 5.11.0 and MSVC 2015 32 bit. After installing MSVC2017 and Qt 5.12.0 I get compile errors in winnt.h.

    typedef struct _IMAGE_HOT_PATCH_HASHES {
    BYTE SHA256[32];
    BYTE SHA1[20];
    } IMAGE_HOT_PATCH_HASHES, *PIMAGE_HOT_PATCH_HASHES;

    C2059: Syntax error: 'constant'
    C2238: unexpected token(s) preceeding ';'

    The errors refer to the line BYTE SHA1[20];

    The items appear to be new in Windows Kits 10. I think MSVC 2015 was using Windows Kits 8.0.

    Not sure if it is a relevant test but I created a small test desktop program in VS2017 and included winnt.h and that program compiles correctly.

    Brian


  • Lifetime Qt Champion

    @BrianN

    Not sure if it is a relevant test but I created a small test desktop program in VS2017 and included winnt.h and that program compiles correctly.

    And after adding:

    typedef struct _IMAGE_HOT_PATCH_HASHES {
    BYTE SHA256[32];
    BYTE SHA1[20];
    } IMAGE_HOT_PATCH_HASHES, *PIMAGE_HOT_PATCH_HASHES;
    

    your minimal program no longer compiles?

    Does it compile if you only add BYTE SHA1[20]; ?

    One more note: _IMAGE_HOT_PATCH_HASHES - symbols starting with underscore _ followed by uppercase letter are reserved for the compiler. Symbols containing two underscores __ anywhere are reserved too.

    Regards



  • @aha_1980

    Sorry I was not clear. Those lines are in winnt.h in the Windows Kits 10. It is not something I have added. They do not appear in Windows Kits 8.

    A minimal app in VS2017 seems to compile ok with winnt.h included.

    Thanks for your help.

    Brian


  • Lifetime Qt Champion

    @BrianN

    So what is your actual problem, i.e. when do you hit that compile error?



  • Hi, SHA1 is an enum in Qt (qtbase/src/3rdparty/rfc6234/sha.h):

    typedef enum SHAversion {
        SHA1, SHA224, SHA256, SHA384, SHA512
    } SHAversion;
    

    Perhaps there's a name collision occurring?



  • @hskoglund

    My simple test was to comment out the lines in winnt.h which is obviously a bad idea but it did allow me to compile and run my program.

    Any ideas how I can progress further in resolving this in a clean way?

    Thanks


  • Lifetime Qt Champion

    @BrianN

    There must be a file in your program where both headers (winnt.h and sha.h) are both included (direct or indirectly). You need to first find out where this happens.

    Then maybe you can work with namespaces to silent this error.



  • @aha_1980

    I have no direct include for "sha.h" so I was trying to figure out how to add /showincludes as an option.

    Is there anyway to get a full view of all included files?

    Thanks

    Brian



  • Hi, turns out Qt is innocent (that sha.h is just a 3rdparty file).
    I think it's a #define in your program that's the culprit. I created a new empty vanilla Qt Widgets program and changed mainwindow.cpp to this:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    //#define SHA1 42
    #include "Windows.h"
    #include "winnt.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    

    Now if you uncomment that #define on line 3 and compile with MSVC2017 you'll get the same error. So look for a similar flavored #define in your program.



  • @hskoglund

    Exactly that. I found the offending item and I can change it.

    Thanks for your help.

    Brian


  • Lifetime Qt Champion

    @BrianN

    Perfect! So it was in your code?

    And please mark this thread as SOLVED so others know a solution was found. Thanks!



  • @aha_1980

    Yes it was in an 'external' part of my code but I have the source and can change it.

    Thanks again for your support.


Log in to reply