How can I tell codegen the argument type is double?

I tried to use -args {1.0}, but it generates a lot of real_T stuff, that's not what I want. I was wondering if it is possible to generate a function whose arguments are of type double ? I can do that using Matlab coder, is it also possible to use codegen to achieve it?

 Accepted Answer

real_T is double by default. Is it a problem for you that the code generates real_T that is a typedef to double, instead of directly generating double ?

4 Comments

Thanks for your reply. And yes, I would like codegen to directly generate double.
What difficulties are you encountering arising from codegen emitting a typedef'd or macro name that resolve to double instead of emitting double directly ?
Oner reason I have for asking about the problem you are encountering, is to try to figure out whether the problem could be resolved by adding a -Dreal_T=double to the command line, which would not change the source code but would cause references to real_T to be compiled directly to double instead of going through a typedef. That could alter some warning messages slightly. (But it could also potentially lead to problems if there is indeed a typedef of that name, as the compiler would then read
typedef double real_T
as if you had written
typedef double double
)
The reason is that I would like to integrate the generated code directly into my program without altering it since that would introduce some potential bugs into my program (because I cannot understand the details of those generated code, it is impossible for me to spot the problems if I mistakenly change the code).
And the workaround you mentioned looks acceptable to me. Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Products

Release

R2022b

Asked:

on 3 Jan 2023

Commented:

on 25 Jan 2023

Community Treasure Hunt

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

Start Hunting!