[capi-sig] (no subject)

Hrvoje Niksic hniksic at xemacs.org
Fri Feb 26 18:11:36 CET 2010

"Goudar, Girish" <Girish.Goudar at goodrich.com> writes:

> Thanks for the quick reply. I can use the struct module at Python side
> and use the pack() function to pack the data. But in the DEOS side I
> need to unpack the data for that I need to use unpack() function. But
> DEOS is not supporting unpack() function. What to do?

I meant to use that you can use struct.pack to create data that can be
interpreted as a structure defined in C, assuming the same architecture
is run on both machines.  Such sharing of data is one of the use cases
of the struct module.  For example:

# python side:
import struct
s = struct.pack('cid', 'A', 10, 20.0)

/* C side: */
struct data_desc {
  char c;
  int i;
  double d;

char *s;
struct data_desc data;

s = read_data_from_network();
memcpy(&data, s, sizeof(data));
/* data.c is now the char
   data.i the int
   data.d the float (double) */

More information about the capi-sig mailing list