Simulink production function block error in br compilation (NAN and INFINITY)

Why does the simulink generated code give the following error, these two objects were generated by himself。


Hi,

until now unfortunately we haven’t found a solution hiere in the community.
But there’s a similar post with at least a workaround by Jeremy, defining NAN and INFINITY by your own after code creation output from Simulink:

Best regards!

1 Like

Hi,

Yes, the work around I have found is to manually define NAN and INFINITY in the auto generated file (see image below). It is rather annoying because you have to do it every time you re-build code from Simulink, but it does resolve the error. Hopefully, someone can come up with a better solution…

Hope that helps in the meantime.
Cheers,
Jeremie

1 Like

you can try to report it to B&R support, maybe they will find way how to fix it/get rid of this problem. Workaround is clear, maybe you can implement script for this.

Hi @j.lagarde,

unfortunately I’m not familiar with Matlab Simulink nor I’m a C programming expert, so please don’t see the following idea as recommendation or expert info :wink:

But to get rid off changing the automatic generated file every time, would it be a possibility to patch the included math.h file in the AS gnuinst installation subfolder? Sure, that’s not a solution / good workaround also, but at least maybe it would help to avoid changing the generated code every time?

Best regards!

2 Likes

Hi Alexander,

yes, that is probably a better solution! I have just tried it and it works for me. I guess you just have to be aware that it applies to all projects that you might have been working on as it is part of the AS gnuinst installation subfolder.

Thanks for the suggestion.

Cheers,
Jeremie

1 Like

Hi,

yeah, you’re right, patching math.h would influence everything that’s using that header file, independent if it’s Simulink generated code or not.
One idea to handle that could be:

  • preparing a patched math.h, but keep also the original one.
  • using the AS configuration pre-build step togehter with a batch file or similar script to decide, if the patched header should be used or not (e.g. by copying the wanted version of math.h into the gnu installation directory before starting compile).

Of course then one more manual step has to be done (setting up the pre-build step), but it could prevent using the patched file if not wanted. But to be honest, I’ve not the possibility right now to try if it really works in that way, or if that causes “trouble” with temp file of the AS project.

Best regards!

Thanks for the replies!