Archived

This forum has been archived. Please start a new discussion on GitHub.

How to define this in slice?

Supposing I have a C function

int ReadFile(int hFile, byte* pBuffer, int nBufLen);

How to define the pBuffer in slice? is sequence<byte> the only way? if so, the nBufLen is no necessary, right?

Thanks.

Comments

  • matthew
    matthew NL, Canada
    Yes, that is correct.

    Matthew
  • Is it possible to define the ReadFile in Slice as

    int ReadFile(int hFile, byte* pBuffer, int nBufLen); ??


    Regards,
    ZhangZQ
  • The slice compiler seems does not support

    int ReadFile(int hFile, byte* pBuffer, int nBufLen);

    If I want to transfer large amount of data, sequence is the only way??
  • zhangzq71 wrote:
    The slice compiler seems does not support

    int ReadFile(int hFile, byte* pBuffer, int nBufLen);

    If I want to transfer large amount of data, sequence is the only way??

    Yes. Passing a pointer to a buffer doesn't make sense because the buffer is in the sender's address space and pointer value would not make sense in the receiver's address space. In other words, what you must transfer is the data itself, not just a pointer to the data. Transmitting a sequence of bytes does exactly that.

    Cheers,

    Michi.