1. passing an array to C api in a windows DLL
- Posted by cp Jul 16, 2010
- 1086 views
I have a C API in a windows DLL that I need to interface with. One of the functions is to create an array of values. The function definition in the header looks like: ddValArray (long hPool,long * array, long MaxSize)
In Euphoria I have the function defined as:ValArray{C_INT,C_POINTER,C_INT},C_INT)
I use ptrArray=allocate(4) before I call the function to create the array pointer and pass ptrArray as the 2nd param.
This seems to be working but is this right? Is an atom 8 bytes? should I use allocate(8) or should I allocate enough space for all the values in the array ie. If the array will be 10 values I would allocate(8*10)?
thanks again for any help.
2. Re: passing an array to C api in a windows DLL
- Posted by jimcbrown (admin) Jul 16, 2010
- 1067 views
I have a C API in a windows DLL that I need to interface with. One of the functions is to create an array of values. The function definition in the header looks like: ddValArray (long hPool,long * array, long MaxSize)
In Euphoria I have the function defined as:ValArray{C_INT,C_POINTER,C_INT},C_INT)
I use ptrArray=allocate(4) before I call the function to create the array pointer and pass ptrArray as the 2nd param.
This seems to be working but is this right? Is an atom 8 bytes? should I use allocate(8) or should I allocate enough space for all the values in the array ie. If the array will be 10 values I would allocate(8*10)?
thanks again for any help.
An atom is a double, which is 64bit or 8 bytes.
However, in C (on Windows) a long is 32bit or 4 bytes. So 4, not 8, is the correct size.
So you want allocate(4*10)