0

I'm trying to integrate CLIPS into my C++ application (QT-project). I already have included the source and header files to the projects. I'm now trying to compile the downloaded source code to see if my basic call within main is working. I'm stuck with the error codes below and do not know to solve them. I also do not want to change the source code of CLIPS which should be just integrated.

void *env;

env = CreateEnvironment();



// The file hello.clp must be in the same directory
// as the CLIPS executable or you must specify the
// full directory path as part of the file name.

EnvLoad(env, "hello.clp");
EnvReset(env);
EnvRun(env,-1);
DestroyEnvironment(env);

Compiling the code leads to the errors:

...\function\core\object.h:113: Fehler: expected unqualified-id before ',' token SLOT_DESC *slots,

and

...\function\core\object.h:211: Fehler: expected unqualified-id before ';' token *slots;

The error points to the code:

struct instance
  {
    ....
   INSTANCE_SLOT **slotAddresses,
                 *slots;
  };

and

struct defclass
  {
    ...
   SLOT_DESC *slots,
             **instanceTemplate;
    ...
  };

This is not my own code I'm just trying to use the functionality provided by CLIPs and integrate it into my own application. CLIPS Programming Guide

s kop
  • 196
  • 4
  • 18
  • 2
    Qt defines a global macro `slots` that interferes with the variable names CLIPS chose. . See this question: [Qt macro keywords cause name collisions](https://stackoverflow.com/questions/22188432/qt-macro-keywords-cause-name-collisions) – Botje May 25 '20 at 13:42
  • `slots` keyword in QT – lupaulus May 25 '20 at 13:52

1 Answers1

0

Try this

1.1 C++ Compatibility

The CLIPS source code can be compiled using either an ANSI C or C++ >compiler. To make CLIPS API calls from a C++ program, it is usually easier to do the integration by compiling the CLIPS source files as C++ files. This removes the need to make an extern "C"declaration in your C++ program for the CLIPS APIs. Some compilersallow you to specify the whether a file should be compiled as C or C++ code based on the file extension. Other compilersallow you to explicitly specify which compiler to use regardless of the extension

(e.g. in gcc the option “-x c++” will compile .c files as C++ files)

For compilers that exclusively use the file extension to determine whether the >file should be compiled as a C or C++ code,it's necessary to changethe .c >extension of the CLIPS source files to a .cppextension.

Community
  • 1
  • 1
lupaulus
  • 358
  • 5
  • 22