Using #defines within generated C++ code

12 visualizaciones (últimos 30 días)
Matt Shellhammer
Matt Shellhammer el 14 de Mayo de 2020
Respondida: Darshan Ramakant Bhat el 15 de Mayo de 2020
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)
#else
#define EXIT (false)
#endif
And I want to use in MATLAB something like the following
exit_entrypoint = false;
if coder.target(RTW)
coder.cinclude('headerWithDefine.h');
% <insert code that sets exit_entrypoint = to EXIT>
end
Let me know if this is possible or if there's a work around. Thanks.

Respuestas (1)

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

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by