[Mono-list] question about Array Embedded Within Structure

Pierre Alain Alran pa-alran at tele2.fr
Sun Oct 16 16:31:59 EDT 2005


Hello,
_i use the managed code :_

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]   //.Ansi
        public struct SHA_CTX
        {
            public uint h0;
            public uint h1;
            public uint h2;
            public uint h3;
            public uint h4; //unsigned long en C 32bits
            public uint Nl;
            public uint Nh; //unsigned long en C 32bits
            [ MarshalAs( UnmanagedType.ByValArray, SizeConst=16 )]
            public uint [] data ;
            public int num;
           
        }

_and before to use a struct SHA_CTX : i do that :_
SHA_CTX m_ShaCtx = new SHA_CTX();
 m_ShaCtx.data = new uint[ 16 ];

_and i use the function : _
[DllImport("libeay32")]
public static extern void SHA1_Init( ref  SHA_CTX c);

_
This code allow me to use the libeay32.so on Linux.
the native code is (sha.h) :_

typedef struct SHAstate_st
    {
    SHA_LONG h0,h1,h2,h3,h4;
    SHA_LONG Nl,Nh;
    SHA_LONG data[SHA_LBLOCK];
    unsigned int num;
    } SHA_CTX;

I have used too , the fixed array syntax (technic 2). Both of this 
technics function very well with mono on Linux.
But on Windows, the technic 1 doesn't function with the CLR of 
Microsoft. But this function if i compile the sources with the 
compilateur of Microsoft.
The technic 2 doesn't function in the two cases because , in the IDE  
visual .NET  , the syntax  :
fixed uint  data [16]; // in the struct SHA_CTX

is not accepted .

do you know if there are some incompatibilities with the bytecode 
generated with the compilateur mono and Microsoft ?
Do you know how can i correct my trouble ? i want to exute my code with 
mono in Linux and the Microsoft's CLR in Windows.

Thank you, sorry for my poor english.



More information about the Mono-list mailing list