coder.Embe​ddedCodeCo​nfig: CustomSourceCode: How to specify multiple lines of code.

Using the CustomSourceCode property of the coder.EmbeddedCodeConfig class, you can add code to be inserted in the generated code. I use it to have a file included into my source code.
Now I want to include multiple files, and so I need to specify multiple lines or custom source code.
How can I specify multiple lines of source code in CustomSourceCode ?
I tried:
cfg.CustomSourceCode = '#include "file1.h"\n#include "file2.h"'
but that just results in
#include "file1.h"\n#include "file2.h"
in my source file, which doesn't compile.

3 件のコメント

TAB
TAB 2012 年 8 月 13 日
編集済み: TAB 2012 年 8 月 13 日
cfg.CustomSourceCode = sprintf('%s\n\r%s',...
'#include "file1.h"','#include "file2.h"');
Please check, is it works for you ?
Hank
Hank 2012 年 8 月 13 日
Yes, this works fine. Thanks for the fast response ! I think it would be a good idea to have this tip added to the manual.
TAB
TAB 2012 年 8 月 13 日
編集済み: TAB 2012 年 8 月 13 日
I have added above line of code in answer. Please accept the answer.

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

 採用された回答

TAB
TAB 2012 年 8 月 13 日
cfg.CustomSourceCode = sprintf('%s\n\r%s',...
'#include "file1.h"','#include "file2.h"');

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品

質問済み:

2012 年 8 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by