The book of inspiration

October 19, 2010

Convert C Headers to .NET

Filed under: tech — Tags: — zproxy @ 12:19 pm

Alexandre Mutel has been busy generating a .NET wrapper for DirectX 11. From what I could gather he is reading .h files in and writing .cs files out.

Note that his post seems to be unavailable.

New OpCodes used by his tool:

  • instruction “calli
  • instruction “sizeof” for generic
  • instruction “cpblk“, memcpy in IL

For future reference to gather some of my thoughts:

It so happens to be that jsc is also providing some support for PInvoke to convert an application to java source code.

Could one at one point program a java application in C# which runs on JVM and uses DirectX via jni? Technically it is possible yes although while jsc uses a version of jni which seems to be bound to the CDecl calling convention.

The names of the exported native functions can be read as described on stackoverflow. For parameters a .h file is required.

What is Cdecl?

ANSI C or POSIX (see the API) portability is a goal

see also:

__cdecl: caller pushes and pops args off stack, args passed right to left.
Older, unmanaged code that was developed by using the standard C libraries can implement functions that take variable numbers of parameters by using a technique that is known as varargs. Only the code that calls these functions knows for certain what it has placed on the stack, so it is the responsibility of the calling code to clean up the stack when the function completes. This is referred to as the Cdecl calling convention. It is the mechanism that unmanaged code that runs on Windows Embedded CE uses (you can use this as a point to select between Cdecl and StdCall nn your code).


See also:


Create a free website or blog at