MATLAB: Is an error returned by the Legacy Code Tool when I specify a C macro in the OutputFcnSpec in Simulink 6.5 (R2006b)

simulink

I am using Legacy Code Tool to incorporate an existing C macro into a C S-Function. When I specify the name of the macro in the OutputFcnSpec in the following manner:
DO.OutputFcnSpec = 'DigitalOutputSignal_Set( u1, u2)';
the following error is returned:
??? Index exceeds matrix dimensions.
Error in ==> slprivate at 12
[varargout{1:nargout}] = feval(function_name, varargin{1:end});
Error in ==> legacy_code at 26
slprivate('lct_gen_sfcn_cmex', varargin{:});
Error in ==> Digital_Interfaces at 50
legacy_code('sfcn_cmex_generate', DO)

Best Answer

When specifying a macro in the OutputFcnSpec, the Legacy Code Tool requires that the user also specify the datatype of the inputs. For example, the following code would be a valid specification:
DO.OutputFcnSpec = 'DigitalOutputSignal_Set(double u1,double u2)';
These datatypes will not appear in the code generated from the model but are required by the Legacy Code Tool during generation of the S-function.