MATLAB Answers

Using #defines within generated C++ code

2 ビュー (過去 30 日間)
Matt Shellhammer
Matt Shellhammer 2020 年 5 月 14 日
回答済み: Darshan Ramakant Bhat 2020 年 5 月 15 日
Is there a way to insert defined values (using #define in an included header file) into MATLAB Coder generated C++ code?
For example,
I want to create a function that breaks if a flag is set (exitFlag). In my included header I have
#ifdef GPP
#define EXIT (exitFlag)
#define EXIT (false)
And I want to use in MATLAB something like the following
exit_entrypoint = false;
% <insert code that sets exit_entrypoint = to EXIT>
Let me know if this is possible or if there's a work around. Thanks.

  0 件のコメント


回答 (1 件)

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2020 年 5 月 15 日
Why dont you include the header-guard before hand and then include the header using coder.cinclude() ?
Below answer is trying to something similar :

  0 件のコメント



Community Treasure Hunt

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

Start Hunting!

Translated by