Include Directive Issue

Hello gentlemen,

I’m trying to use #include “abc.h” directive but I’m getting errors when the C block is being compiled.

C block code in QSPICE:

// Automatically generated C++ file on Tue May 28 11:00:28 2024
//
// To build with Digital Mars C++ Compiler:
//
//    dmc -mn -WD cblock_include_test_x1.cpp kernel32.lib
#include "controller_pid.hpp"
#include <stdint.h>

union uData
{
   bool b;
   char c;
   unsigned char uc;
   short s;
   unsigned short us;
   int i;
   unsigned int ui;
   float f;
   double d;
   long long int i64;
   unsigned long long int ui64;
   char *str;
   unsigned char *bytes;
};

bool init = true;
PID_t ControllerPID_Obj;

// int DllMain() must exist and return 1 for a process to load the .DLL
// See https://docs.microsoft.com/en-us/windows/win32/dlls/dllmain for more information.
int __stdcall DllMain(void *module, unsigned int reason, void *reserved) { return 1; }

// #undef pin names lest they collide with names in any header file(s) you might include.
#undef OUT
#undef FB

extern "C" __declspec(dllexport) void cblock_include_test_x1(void **opaque, double t, union uData *data)
{
   double  FB  = data[0].d; // input
   double &OUT = data[1].d; // output

// Implement module evaluation code here:

   if(init){

      PIDinit(&ControllerPID_Obj, 1.0f, 0.1f, 0.0f, 1.0f);
      PIDSetRef(&ControllerPID_Obj, 10);
      init = false;
   }

   OUT = PIDRun(&ControllerPID_Obj, FB);


}

Here is the compiler output:

link cblock_include_test_x1,cblock_include_test_x1.dll,,verilated+kernel32,cblock_include_test_x1/noi;
OPTLINK (R) for Win32  Release 8.00.16
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
cblock_include_test_x1.obj(cblock_include_test_x1) 
 Error 42: Symbol Undefined ?PIDSetRef@@YAXPAUPID_st@@M@Z (void cdecl PIDSetRef(PID_st *,float ))
cblock_include_test_x1.obj(cblock_include_test_x1) 
 Error 42: Symbol Undefined ?PIDinit@@YAXPAUPID_st@@MMMM@Z (void cdecl PIDinit(PID_st *,float ,float ,float ,float ))
cblock_include_test_x1.obj(cblock_include_test_x1) 
 Error 42: Symbol Undefined ?PIDRun@@YAMPAUPID_st@@M@Z (float cdecl PIDRun(PID_st *,float ))

--- errorlevel 3

controller_pid_hpp

#ifndef CONTROLLER_PID_H__
#define CONTROLLER_PID_H__

typedef struct PID_st{

   float ref;        // reference value
   float fb;         // feedback value
   float err;        // error

   float sat_high;
   float sat_low;    //
   float integral;   // integration value
   float integral_prev;
   float out_p;
   float out_i;
   float out_d;
   float out;

   float kp;   // proportional coef
   float ki;   // integral coef
   float kd;   // derivative coef
   float kc;   // anti-windup
}PID_t;

/**
 * @brief 
 * 
 * @param pidObj 
 * @param feedback 
 * @return float 
 */
float PIDRun(PID_t *pidObj, float feedback);

/*
* @brief
*/
void PIDinit(PID_t *pidObj, float kp, float ki, float kd, float kc);


/**
 * @brief 
 * 
 * @param pidObj 
 * @param ref 
 */
void PIDSetRef(PID_t *pidObj, float ref);

/**
 * @brief 
 * 
 * @param pidObj 
 * @return float 
 */
float getPIDref(PID_t *pidObj);

/**
 * @brief 
 * 
 * @param pidObj 
 * @return float 
 */
float getPIDerror(PID_t *pidObj);
#endif  // CONTROLLER_PID_H__

controller_pid.cpp

#include "controller_pid.hpp"

float PIDRun(PID_t *pidObj, float feedback){

   pidObj->fb = feedback;
   pidObj->err = pidObj->ref - pidObj->fb;

   pidObj->out_p = pidObj->err * pidObj->kp;
   pidObj->out_d = pidObj->err * pidObj->kd; // Wrong implementation for derivative

   pidObj->integral = pidObj->err * pidObj->ki;
   pidObj->out_i = pidObj->integral + pidObj->integral_prev;
   pidObj->integral_prev = pidObj->out_i;

   pidObj->out = pidObj->out_p + pidObj->out_i + pidObj->out_d;
   return pidObj->out;
}

void PIDinit(PID_t *pidObj, float kp, float ki, float kd, float kc){

   pidObj->kp = kp;
   pidObj->ki = ki;
   pidObj->kd = kd;
   pidObj->kc = kc;

   /*pidObj->out_i = 0;
   pidObj->integral_prev = 0;
   pidObj->fb = 0;
   pidObj->ref = 0;*/
}

void PIDSetRef(PID_t *pidObj, float ref){

   pidObj->ref = ref;
}

void PIDSetFeedback(PID_t *pidObj, float feedback){

   pidObj->fb = feedback;
}

float getPIDref(PID_t *pidObj){

   return pidObj->ref;
}

float getPIDerror(PID_t *pidObj){

   return pidObj->err;
}

What am I missing?
Thank you