C code not compiling

I was trying to simulate the space vector modulation using a c code.
But I am getting error how to solve it.
File attached for reference.

SPWM.qsch (4.5 KB)
spwm_x5.cpp (4.8 KB)

Hi, Techman_7.

Attached is a version of the *.cpp that compiles without errors using the DMC compiler. I added defintions for fmax() and fmin() and changed the evaluation function name to match the QSpice schematic DLL name. Not tested beyond that.

Things to know:

  • The DMC compiler included with QSpice is ancient. Development on the compiler ended in the early 2000’s. It supports C99 and C++98 standards (in theory). I strongly recommend using more modern tools (compilers, IDEs, etc.).
  • QSpice runs the DMC compiler in C++ mode. It’s probably better to use C++ includes (e.g., <cmath>) instead of C includes (e.g., "math.h"). However, that didn’t actually fix the compiler errors so I added the explicit fmin()/fmax() definitions as a quick solution.

If you’ve not already checked out my QSpice repository, you might want to do so. There are links to the DMC documentation and information about using more modern compilers (MinGW and MSVC) and IDEs (e.g., the free Visual Studion Code IDE). And you’ll find lot’s of C-Block code development information there.

Hope that helps.

–robert

spwm_x5.cpp (5.0 KB)

2 Likes