Struct with doubles

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Struct with doubles

Schwab,Wilhelm K
Hello all,

I am faced with some win32 software that uses a structure like

struct gizmo {
  double x; y; z;
  double q[4];
}

Would it be legal to treat that as

struct gizmo {
  double x; y; z;
  double q0; q1; q2; q3;
}

and then let Pharo define the fields?  This is running on 32 bit winxp.  A colleague is doing 3D magic with the resulting numbers, but Weird things appear to be happening.  I am looking for ways that I might be causing them.  It is also possible that the gizmo to which we are interfacing is just plain broken.

Bill



Reply | Threaded
Open this post in threaded view
|

Re: Struct with doubles

Igor Stasenko
On 28 May 2010 01:28, Schwab,Wilhelm K <[hidden email]> wrote:

> Hello all,
>
> I am faced with some win32 software that uses a structure like
>
> struct gizmo {
>  double x; y; z;
>  double q[4];
> }
>
> Would it be legal to treat that as
>
> struct gizmo {
>  double x; y; z;
>  double q0; q1; q2; q3;
> }
>
yes.

But there could be other issues, like fields alignment (which is not
for gizmo , since its fields are 8-bytes wide).


> and then let Pharo define the fields?  This is running on 32 bit winxp.  A colleague is doing 3D magic with the resulting numbers, but Weird things appear to be happening.  I am looking for ways that I might be causing them.  It is also possible that the gizmo to which we are interfacing is just plain broken.
>

At the last resort, just compile a simple C program which prints an
offsets to these fields, like:

gizmo z;

printf ("%d\n" , &(z.q[3]) - &z  );


> Bill
>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.