Effacer les filtres
Effacer les filtres

How can I use arithmetic operations (for C pointers) using coder.opaque types?

1 vue (au cours des 30 derniers jours)
Hello everyone,
I am into a project that uses coder.opaque to create char*, and I need memcpy to another another variable coder.opaque type, applying arithmetic operations to that "pointers".
Following I show you an example to explain what I am saying better:
first = coder.opaque('char*');
last = coder.opaque('char*');
def = coder.opaque('char*');
def = coder.ceval('(char*) malloc', 100);
% some operations %
memcpy(def, first+1, last-first); % Error. Expected either a <basic types>. Found a coder.opaque
How can I apply, or do the same, '+'/'-' operators to coder.opaque variables pointers, for move into the memory?
Regards,
Marcel

Réponse acceptée

Marcel Vilalta i Soler
Marcel Vilalta i Soler le 15 Mai 2017
Well,
I obtain a solution about this problem, but I am not very satisfied...., if anyone could do it better, please, share!.
In my case, I generate a C code, and with x=coder.opaque('char*', 'info+1'), when I use x on the parameters for coder.ceval() on the generated code it writes literally its value (info+1).
Regards,
Marcel

Plus de réponses (0)

Catégories

En savoir plus sur External Code Integration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by