0

While it is known to use templates for class arguments, I had the surprise to find that the following class definition in the `stdafx.h:

struct fints {
/*variables paramétriques de la série financière*/
string desc{ "" };                      
USHORT periode{ 1 };                        
fints(const auto& d, const matrice& A, const Representation& r = Representation::absolu) noexcept;
...
};``

with appropriate definition in stdafx.cpp, was accepted in the MSVC 2022 C++ compiler, but generated an error with the MATLAB compiler for generating an mex file:

error LNK2019: symbole externe non r‚solu "public: __cdecl fints::fints<class vecteur>(class vecteur const &,class matrice const &,enum Representation const &)"

To solve the problem, I had to fall back to the traditional definition, replacing the auto by an already defined class, eg:

fints(const auto& d, ...
into
fints(const vecteur& d,

I designed a meta compiler for MATLAB, transforming a series of functions written in C++ into mexFunctions that can be used in MATLAB. Arguments from MATLAB workspace are converted into C++ classes, and vice_versa.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 4
    Using `auto` here makes the function a template, so you must define it in the header. Does this answer your question? – HolyBlackCat Apr 05 '23 at 21:22

0 Answers0