What's the difference between the two pointer operators in the code gen?

In code generation using Simulink coder the pointers can be used in two different ways:
(*ptr).variable or ptr->variable
What is the difference? When coder uses one or the other?
thanks

 채택된 답변

James Tursa
James Tursa 2017년 7월 5일

0 개 추천

I don't know why the Coder will produce one form vs the other form, but by definition in the C language they mean exactly the same thing to the C compiler.

댓글 수: 3

Exactly, that's why my question. Maybe it does that for specific storage classes. I noticed that for inputs the -> is used and for mpt signals the (*ptr) is more common. Thanks for the reply!
James Tursa
James Tursa 2017년 7월 5일
편집: James Tursa 2017년 7월 5일
My first WAG is that maybe two different groups of people at TMW produced the Coder logic for the two different cases, and one group preferred the (*ptr).variable syntax while the other group preferred the ptr->variable syntax.
In my experience (*ptr).variable becomes more probable with mechanical code generation that is traversing data structures looking for the correct field, whereas ptr->variable is more probable when you already know you are at the correct location. They mean the same, but when you are doing mechanical code generation you tend to be thinking of "current location" as an emphasis that tends to lead more to *ptr syntax.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

질문:

2017년 7월 4일

댓글:

2017년 7월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by