Error using legacy_code (doubleIt Example)

3 views (last 30 days)
Hey there, ive got some problems. I was rebuilding the example "Integrate C Functions Using Legacy Code Tool" and got some errors after "legacy_code('sfcn_cmex_generate', def);".
Here is my code:
---
doubleIt.c:
#include "doubleIt.h"
double doubleIt(double inVal)
{
return(2*inVal);
}
---
doubleIt.h:
#ifndef DOUBLEIT_H
#define DOUBLEIT_H
double doubleIt(double inVal);
#endif
---
Matlabcode:
def = legacy_code('initialize')
def.SourceFiles = ('doubleIt.c');
def.HeaderFiles = ('doubleIt.h');
def.SFunctionName = 'ex_sfun_doubleit';
def.OutputFcnSpec = 'double y1 = doubleIt(double u1)';
legacy_code('sfcn_cmex_generate', def);
---
Errors after typing "legacy_code('sfcn_cmex_generate', def)":
Error using lct_pValidateStructure (line 44) The field "HeaderFiles" is of class "char" and must be of class "cell"
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+legacycode\@LCT\LCT.p>LCT.LCT (line 43)
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+legacycode\@LCT\legacyCodeImpl.p>iCreateLctObject (line 171)
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+legacycode\@LCT\legacyCodeImpl.p>legacyCodeImpl (line 52)
Error in legacy_code (line 87) [varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
---
How do i fix it? :X
Regards, Alex

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 20 May 2013
The documentation uses curly braces (which defines cell-arrays) to define the SourceFiles and HeaderFiles fields (you are using regular parentheses):
...
def.SourceFiles = {'doubleIt.c'};
def.HeaderFiles = {'doubleIt.h'};
...
  1 Comment
Alexander
Alexander on 20 May 2013
Edited: Alexander on 20 May 2013
Thank you.
I've observed this too, later. ;)
Regards, Alex

Sign in to comment.

More Answers (1)

Alexander
Alexander on 19 May 2013
#push

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!