Borrar filtros
Borrar filtros

C++ pointers and variables

1 visualización (últimos 30 días)
Carlos
Carlos el 3 de Abr. de 2017
Comentada: Guillaume el 4 de Abr. de 2017
Dear experts,
I am trying to convert the following C++ code to a matlab code:
double buffer = 72.0;
double *pBuffer = &buffer;
t = sizeof(buffer));
Does anyone know to solve this question?
Thank you in advance.
Carlos

Respuesta aceptada

Jan
Jan el 3 de Abr. de 2017
buffer = 72;
You do neither need a pointer in Matlab nor does the the size of the type matter.
  4 comentarios
Carlos
Carlos el 4 de Abr. de 2017
Thank you Jan. I made it.
Guillaume
Guillaume el 4 de Abr. de 2017
If you're using this filexchange sizeof you're using it incorrectly. The correct code should have been:
calllib(libstring,'SetSystemParameter',MAXIMUM_RANGE,pRecord31,sizeof('double'));
Or you could just not have bothered and pass 8 directly, since scalar double are always 8 bytes.
Note that matlab may have been clever enough to automatically make the conversion from double to void pointer, so possibly this may have been enough:
value = 72;
calllib(libstring,'SetSystemParameter',MAXIMUM_RANGE, value, 8)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by