Question

I apparently have done something really wrong, and there must be a simple solution. I've a USB device that I'm trying to talk to that uses a FTDI USB to RS232 converter. They provide a driver library (ftd2xx.dll) and header file (ftd2xx.h) as a programming interface. I created a simple project in QtCreator that, to this point does nothing. It compiles and runs fine. However, as soon as I include ftd2xx.h, I get a host of errors. For example:

typedef PVOID  FT_HANDLE;
typedef ULONG  FT_STATUS;
typedef void (*PFT_EVENT_HANDLER)(DWORD,DWORD);
WORD VendorId;

These lines, and many similar to them, cause these errors:

‘PVOID’ does not name a type
‘ULONG’ does not name a type
Typedef ‘PFT_EVENT_HANDLER’ is initialized (use decltype instead)
‘WORD’ does not name a type

I'm not sure where to go from here. I've spoken to FTDI support and they say the only header file I need is ftd2xx.h, which is the one that is causing the issues. I'm overlooking something here.

Was it helpful?

Solution

You need to do the following:

#include <Windows.h> // comes first
#include "ftd2xx.h" // comes *after* Windows.h

The FTDI include file is broken as it doesn't properly include the windows header even though it relies on windows types. You must do it yourself instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top