Visual Studio Paho MQTT Error C2238 unexpected token(s) preceding ‘;’

If you’re receiving errors like the following when trying to build a project in Visual Studio 2017 using the Paho C client:

Then there is a quick fix, the problem seems to revolve around the following for DLLImport & DLLExport in the Paho header files:

The catch here is that neither WIN32 nor WIN64 will be defined as instead either _WIN32 or _WIN64 will be defined.

So a quick fix is to define either WIN32 or WIN64 in your project’s ‘Preprocessor Definitions’ depending on whether you are targeting x86 (32bit) or x64 (64bit).

Here are some of the other errors you might see when you have this problem:

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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