What's the difference between the two pointer operators in the code gen?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rusczak
le 4 Juil 2017
Commenté : Walter Roberson
le 5 Juil 2017
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
0 commentaires
Réponse acceptée
James Tursa
le 5 Juil 2017
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 commentaires
James Tursa
le 5 Juil 2017
Modifié(e) : James Tursa
le 5 Juil 2017
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.
Walter Roberson
le 5 Juil 2017
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!