c++mingwc-preprocessorcodeblocksnui

Preprocessor error C++


I am using Code::Blocks and MinGW to compile and run OpenCV together with CL NUI so that I can get Kinect-Data into OpenCV. OpenCV works fine but CL NUI does not because I encounter some problems with the API that have to do with the preprocessor which I am not really familiar with.

This is the code from the API I have it included in my project and I only get this error:

"C:\Program Files (x86)\Code Laboratories\CL NUI Platform\SDK\Include/CLNUIDevice.h:19:1: Fehler: das Einfügen von »)« und »int« ergibt kein gültiges Präprozessor-Token"

Translation: "...CLNUIDevice.h:19:1: Error: adding »)« and »int« results in no valid preprocessor-token"

Maybe someone with knowledge about preprocessors can help me?

Here is my code for the project, but I cannot imagine how this would mess up things, but who knows, since I could not test it.


Solution

  • In the line

    #define IMPORT(type) extern "C" __declspec(dllimport)## type __cdecl
    

    remove ##, giving you

    #define IMPORT(type) extern "C" __declspec(dllimport) type __cdecl
    

    ## is the token pasting operator, and ) can't be part of a token (it is a token by itself). I presume the preprocessor used by the authors of the code was nonconforming if it accepted it, but I have no idea why they thought it should be needed there.