Test and Measurement Forum

integer sizes

Post your .Net discussions here

integer sizes

Postby AnthonyCSheehy » Tue May 29, 2007 3:20 pm

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
AnthonyCSheehy
Active User
Active User
 
Posts: 7
Joined: Fri May 04, 2007 10:18 am

Postby markB » Wed May 30, 2007 1:53 pm

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/library/ms235282(VS.80).aspx, for more info.
Regards

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

Postby AnthonyCSheehy » Wed May 30, 2007 2:17 pm

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
AnthonyCSheehy
Active User
Active User
 
Posts: 7
Joined: Fri May 04, 2007 10:18 am


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests