Notes on Qt 6 with qzxing: “error C3861: ‘UINT32_C’: identifier not found”

Tags: , , ,

I was asked to fix this error that appeared porting a Qt 5 app using qzxing to Qt 6 on Windows:

..\..\Qt\6.5.3\msvc2019_64\include\QtCore/qhashfunctions.h(55): error C3861: 'UINT32_C': identifier not found
..\..\Qt\6.5.3\msvc2019_64\include\QtCore/qhashfunctions.h(57): error C3861: 'UINT32_C': identifier not found
..\..\Qt\6.5.3\msvc2019_64\include\QtCore/qhashfunctions.h(63): error C3861: 'UINT64_C': identifier not found
..\..\Qt\6.5.3\msvc2019_64\include\QtCore/qhashfunctions.h(65): error C3861: 'UINT64_C': identifier not found

The reason for this error comes from the fact that qzxing seems to be providing its own version of stdint.h: https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/src/zxing/win32/zxing/msvc/stdint.h#L4.

The header has some macros guarding the definition of the types here https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/src/zxing/win32/zxing/msvc/stdint.h#L129 and here https://github.com/ftylitak/qzxing/blob/641da3618b3c3e386d32c70a208a49df72839c0a/src/zxing/win32/zxing/msvc/stdint.h#L226.

Solution is, therefore, to define those macros in the app:

win32:DEFINES += __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS

Leave a Reply

Your email address will not be published. Required fields are marked *