equivalent of C typedef in c# .net -



equivalent of C typedef in c# .net -

i have code of c:

class="lang-c prettyprint-override">typedef void (* fps_positioncallback) ( unsigned int devno, unsigned int length, unsigned int index, const double * const positions[3], const bln32 * const markers[3] );

and need write same thing in c#. idea?

you need define delegate , mark unmanagedfunctionpointer

e.g.

[unmanagedfunctionpointer(callingconvention.stdcall)] public delegate void fps_positioncallback( int32 devno, int32 length, int32 index, [marshalas(unmanagedtype.lparray, sizeparamindex = 3)]double[] positions, [marshalas(unmanagedtype.lparray, sizeparamindex = 3)]double[] markers);

i assuming bln32 double, may need cdecl instead of stdcall , int16 instead of int32.

you can pass c-function e.g. might declared this

[dllimport("fpslib.dll")] public static extern void setpositioncallback([marshalas(unmanagedtype.functionptr)] fps_positioncallback callbackpointer);

then execute e.g.

fps_positioncallback callback = (devno, length, index, positions, markers) => { }; setpositioncallback(callback);

you have lot of fiddling right.

c# typedef

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -