How do i use typedefs, enums declared in my C plugin .h?

I am learning to write C plugins for Unity.

From C# I can access functions declared in my C code using dllImport.
But now I would like to also access typedef enums etc declared in it .h file.

For instance in my C .h file I have something like:

typedef struct _myStruct  * myStruct_handle_t;

and

void          myCFunction(  myStruct_handle_t myStruct );

now when i try importing this function in C# script with dllImport, I get the following error:

Assets/PluginImport.cs(28,49): error CS0246: The type or namespace name `myStruct_handle_t’ could not be found. Are you missing a using directive or an assembly reference?

How can I use types defined in my C code? For instance is there a way to include my .h file in my c# script?

thanks,

Baba

you need to redefine that in C# with [StructLayout(LayoutKind.Sequential)] check out this msdn page it has some good example (and that is a rare thing :D) of what you have to do :

Actually in my case the type i want to use is an opaque pointer. Therefore I do not need (want) to expose the internals of my struct to the c# script. Therefore the solution is to simply write IntPtr instead of myStruct_handle_t in my dllImport extern declaration and it works.

For the enum I just redefined them as public enum myEnum_t : int { /* … enums, */} in my C# script

_met44 solution seems to be the correct solution in the case where you want to have access to your struct fieldsfrom C# but I haven’t tried it.