QCustomPlot Discussion and Comments

conflicting declaration in files minwindef.h and winsmcrd.hReturn to overview

I just included qcustomplots library in my qt application. But, while compiling its throwing 2 errors as:

conflicting declaration 'typedef short unsigned int WORD'
conflicting declaration 'typedef WORD UWORD''

Without including qtcustom plots it works extremely fine.

OS: Windows
Using: Qt 5.12

Any easy solutions?

Tried by demoting widget to QWidget again....it worked fine.
Promoted it again to qcustomplot, again showing same error.

The issue here is that 'WORD' and 'UWORD' are already defined by windows. i dont know why they would be used in the qcustomplot code though, as they aren't platform independent. i dont see it in my version, (i'm on 1.x). i suggest putting

#ifndef __WIN32
around those declarations

QCustomPlot doesn't use such general typedefs. The problem you're seeing is outside of QCP, maybe the Qt printsupport module?

I am getting this error as well and it only happens when I have qcustomplot .h included.

I have tried removing the printsupport module from my .pro file but I still get the error about the conflicting typedef declarations.

I simply added the following line to the top of the mainwindow.h for the plot-examples project and it gives this conflicting error:

typedef    quint32    DWORD;

What might cause this behavior?

What compiler/version are you using? Those .h files look like they're from MinGW, not Microsoft.

I am using the following:

Compiler: MinGW 7.3.0 64-bit
Qt Version: 5.12.9

I am able to build the examples fine and run them with this setup.

However, when I add the typedef line to example/plots/mainwindow.h, I get the conflicting declaration error.


I only have newer versions of Qt (5.15.x and 6.4.x) and MinGW (8.1.0 and 11.2.0) installed. I don't get conflicts using these.

Any reason not to go to later versions? (Well, maybe there are good reasons: to get the latest in the Qt 5.15 series, you have to build it from scratch, a painful task at best. 6.x might require significant source code changes. Replacing QRegEx with QRegularExpression was the big one for me.)

Currently, that setup is what I have been given to work with, but if it continues to be an issue I may have to try the versions you are using.

In the interim, I have had to adjust my code so that my definitions of DWORD, WORD, etc. are in a namespace that I created:

namespace custom {
typedef quint32 DWORD;
} // namespace custom


void foo()
    custom::DWORD    dwValue = 0;

    // ...use qcustomplot stuff

It is not ideal, but currently "works".