MATLAB Coder "Style" Options when Generating .mex-File

3 ビュー (過去 30 日間)
Greg
Greg 2014 年 7 月 2 日
コメント済み: Greg 2014 年 7 月 2 日
When using the MATLAB Coder to create a .mex-file, the "Code Style" settings in the GUI settings menu are not available. They only appear to be available when generating a Static Library, Dynamic Library, or Executable.
My specific issue with this is that I not longer have access to the "Maximum Identifier Length" setting. Because I can't increase this from 31, some fields in structures in my code are being mangled, which means that the typedefs don't match external code that is trying to interface with those typedefs.
Is there any other way to change the maximum identifier length setting?

採用された回答

Ryan Livingston
Ryan Livingston 2014 年 7 月 2 日
Using coder.cstructname is one means of integrating structs which are also used in external code. You could define the structure type in a header file, customDefs.h and then include the definition of that header in your MATLAB code like so:
function y = foom(x)
coder.cstructname(x, 'customImportedStruct', 'extern', 'HeaderFile', 'customDefs.h');
y = 2*x.fieldWithVeryVeryVeryVeryLongName;
and generate code:
str.fieldWithVeryVeryVeryVeryLongName = 12; codegen foom -args str -c -report
You will see that the field names are preserved and that the file foo_types.h includes customDefs.h.
This approach also lets you hand-tailor the typedef for your structure so that it is predictable and consistent across the generated code and your external code.
  1 件のコメント
Greg
Greg 2014 年 7 月 2 日
Thanks, that works well. I had actually already been using the coder.cstructname function, but hadn't thought to give it an external header file.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by