MATLAB: Is there a way to access class data and methods with the scope (::) operator with the Legacy Code Tool in Simulink 6.4 (R2006a)

codelegacysimulinktool

I am using the Legacy Code Tool (LCT) to import some existing C++ code. In my .cpp function calls, I am accessing class data and methods via the scope operator ( :: ). I am not sure how this would translate over to the wrappers for methods used in Simulink.

Best Answer

This is a limitation in the Legacy Code Tool.
You can workaround the limitation by writing simple preprocessor macros (if the methods you want to call are static):
#define Common_DDM_Type Common::DDM_Type
#define CCommon_vectorType CCommon::vectorType
...
#define CCommon_computeVectorDotProduct CCommon::computeVectorDotProduct
...
You will have to create the bus objects corresponding to the Common::DDM_Type and CCommon::vectorType structures. Do not forget to specify the header file for each bus object. The LCT function specification should be like:
def.OutputFcnSpec = 'FDCommandType y1 = computeFlightDirectorCommand(
int32 u1,
Common_DDM_Type u2,
Common_DDM_Type u3,
Common_DDM_Type u4,
Common_DDM_Type u5,
CCommon_vectorType u6,
CCommon_vectorType u7, double u8);'
This is a common workaround.