I have a C API like that:
==== C-API.h ====
typedef double NSTimeInterval;
NSTimeInterval GetTimeSince1970();
===============

Now I have a code generator parsing the headers and automatically
generating:
==== Generated.cs ====
class Wrapper
{
[DllImport(...)]
public extern static NSTimeInterval GetTimeSince1970();
}

where
[StructLayout(LayoutKind.Sequential)]
struct NSTimeInterval
{
public seconds timeinterval;
}
========

but that doesn't seem to work.
while the C call return correct value, C# test return me stupid random like
value.

what's even weirder I think it used to work well, the only breaking change I
could see is that I'm now using .NET 2.0 final release.

Any tips/thoughts?

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>

Re: interop question by Lloyd

Lloyd
Tue Dec 20 01:25:09 CST 2005

in fact my wrapper is in managed C++.
I just redefined NSTimeInterval as it is in the (missing) C header and it
works nicely!

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
"Lloyd Dupont" <net.galador@ld> wrote in message
news:%23bEbzoSBGHA.1180@TK2MSFTNGP09.phx.gbl...
>I have a C API like that:
> ==== C-API.h ====
> typedef double NSTimeInterval;
> NSTimeInterval GetTimeSince1970();
> ===============
>
> Now I have a code generator parsing the headers and automatically
> generating:
> ==== Generated.cs ====
> class Wrapper
> {
> [DllImport(...)]
> public extern static NSTimeInterval GetTimeSince1970();
> }
>
> where
> [StructLayout(LayoutKind.Sequential)]
> struct NSTimeInterval
> {
> public seconds timeinterval;
> }
> ========
>
> but that doesn't seem to work.
> while the C call return correct value, C# test return me stupid random
> like value.
>
> what's even weirder I think it used to work well, the only breaking change
> I could see is that I'm now using .NET 2.0 final release.
>
> Any tips/thoughts?
>
> --
> Regards,
> Lloyd Dupont
>
> NovaMind development team
> NovaMind Software
> Mind Mapping Software
> <www.nova-mind.com>
>