integer sizes

 
Post new topic   Reply to topic    Pico Technology Forum Index -> .Net Languages (C#, VB.Net, .)
Author Message
AnthonyCSheehy
Active User
Active User


Joined: 04 May 2007
Posts: 7

PostPosted: Tue May 29, 2007 3:20 pm    Post subject: integer sizes Reply with quote

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.
Back to top
markB
Site Admin
Site Admin


Joined: 27 Mar 2007
Posts: 80
Location: Cambridgeshire,UK

PostPosted: Wed May 30, 2007 1:53 pm    Post subject: Reply with quote

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, [url]http://msdn2.microsoft.com/en-us/library/ms235282(VS.80).aspx[/url], for more info.
Back to top
AnthonyCSheehy
Active User
Active User


Joined: 04 May 2007
Posts: 7

PostPosted: Wed May 30, 2007 2:17 pm    Post subject: Reply with quote

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Pico Technology Forum Index -> .Net Languages (C#, VB.Net, .)
All times are GMT
Page 1 of 1

 


Pico Technology topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group