Why is a doublePtr output argument actually a double?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
In this page below titled "Working with Pointer Arguments", the sample function (multDoubleRef) is said to return the second output argument (xval) as a value of type double. As a matter of fact, xval indeed functions as a double variable. However, the function prototype indicates that it should be of type doublePtr. Why is there an inconsistency? Thanks.
Example:
x = 15;
xp = libpointer('doublePtr',x);
[xobj,xval] = calllib('shrlibsample','multDoubleRef',xp)
xobj =
lib.pointer
xval =
75
Function Prototype
[lib.pointer, doublePtr] multDoubleRef(doublePtr)
0 commentaires
Réponses (1)
Philip Borghesani
le 15 Fév 2013
This is a convenience for the user. When MATLAB knows the size and type of a simple output pointer it automatically copies the output values to MATLAB arrays. The original(possibly modified) values and pointer from the inputs are still intact and can be used when a copy is not desired.
The same conversions are done on input. This is a reasonable call:
[~,newvalue]=calllib('shrlibsample','multDoubleRef',5);
Note that in this case the first output pointer return value should not be used because it points to a temporary value that has already been deleted.
0 commentaires
Voir également
Catégories
En savoir plus sur Call C from MATLAB 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!