C function prototype of a simulink function is not correctly configured as desired in generated code
Show older comments
Hello everyone,
I'm using a simulink function block to generate a function that is going to be integrated into an external project.
The desired function prototype has been configured as below. Here, the function has a return value.

However, in the generated source file, the function is defined in the following way:
// Function Definition
void s16_eeprom_read_block(uint16_T ou16_BlockNumber, int16_T *rty_s16_ErrorFlag)
{
// Algorithm Implementation
}
// Function Declaration
extern int16_T s16_eeprom_read_block(uint16_T ou16_BlockNumber);
As we can see, the function doesn't have any return value according to its definition. Instead, this value has been replaced with a reference. As for function declaration, it is just what I desired.
Since this function has to be called and its return value has to be evaluated in the project, this mistake will lead to a compilation error.
I have deleted all of the generated files and tried to generate code again, but it didn't help.
In addition, my MATLAB version is R2018a. I think it may be a bug of simulink function since years ago, because this problem also occured while using earlier versions.
Is there anyone who can help me to solve this problem? Thank you!
4 Comments
Xiaojie Qiu
on 27 Aug 2018
Nick Sarnie
on 2 Sep 2018
Hi Xiaojie,
I wasn't able to reproduce this behavior using a simple demo. I've attached the example I created to this post. Can you let me know what is different in our models?
Thanks!
Xiaojie Qiu
on 3 Sep 2018
Nick Sarnie
on 3 Sep 2018
Hi Xiaojie,
Thanks for letting me know. If you are able to reproduce either of those issues, please reach out to Technical Support. They can work with my team to investigate further.
Thanks, Nick
Answers (0)
Categories
Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!