integer sizes

Post your .Net discussions here
Post Reply
AnthonyCSheehy
User
User
Posts: 7
Joined: Fri May 04, 2007 10:18 am

integer sizes

Post by AnthonyCSheehy »

I am writing some .net 2.0 applications that query the PicoScope.

One thing I have noticed is the difference in stated integer sizes. For example the manual defines the time_interval pointer for ps3000_get_timebase as a long. However, it only returns a 32 bit integer.

If I try to fit a long (64bit) to stated long function parameters I often get a mismatch error between the managed and unmanaged code, or an attempt to write protected memory error.

As it goes, assigning a int64 to this value does not return an error, but the value returned does not go above 2147483648... which is 32 bits?

Would it be possible for someone to publish the correct byte sizes for the function definitions in the manual.
Anthony Sheehy
MCP

markB
Site Admin
Site Admin
Posts: 83
Joined: Tue Mar 27, 2007 9:43 am
Location: Cambridgeshire,UK

Post by markB »

Hi

A win32 long is only a 32 bit integer and is not equivilent to a managed Int64. You should use an Int32 for both win32 int and long.

Take a look at the "Calling Native Functions from Managed Code" topic of the msdn library, http://msdn2.microsoft.com/en-us/librar ... S.80).aspx, for more info.
Regards

Mark

AnthonyCSheehy
User
User
Posts: 7
Joined: Fri May 04, 2007 10:18 am

Post by AnthonyCSheehy »

Ah - thank you.

I think that the confusion is that I am writing in VB.net. (I suppose I should have mentioned that to make it clearer - my mistake.)

In VB, Long data type is, in fact, 64-bits. I guess that is what is confusing me.

Ah, yes I understand. The microsoft document includes a mapping between win32 types and the CLR type. Strange that the long and integer types are the same length. I wonder if that's a throwback to the 16 bit days...

Thanks
Anthony Sheehy
MCP

Post Reply