Skip to content

Instantly share code, notes, and snippets.

@zzeroo
Last active September 17, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zzeroo/8ff864cbeb45912e6854 to your computer and use it in GitHub Desktop.
Save zzeroo/8ff864cbeb45912e6854 to your computer and use it in GitHub Desktop.
CDPATH="${ZSH_VERSION+.}:" && cd . && /usr/bin/valac --vapidir ../ --pkg libmodbus --pkg posix -g -C unit-test-server.vala
unit-test-server.vala:224.37-224.41: error: Incompatible operand
Posix.send(w_s, (void*)(req+i), 1, MSG_NOSIGNAL);
^^^^^
CDPATH="${ZSH_VERSION+.}:" && cd . && /usr/bin/valac --vapidir ../ --pkg libmodbus --pkg posix -g -C unit-test-server.vala
unit-test-server.vala:224.29-224.42: error: Pointer arithmetic not supported for `void*'
Posix.send(w_s, (void*)(req)+i, 1, MSG_NOSIGNAL);
^^^^^^^^^^^^^^
@zzeroo
Copy link
Author

zzeroo commented Sep 17, 2015

The correct cast looks like

Posix.send (w_s. (uint8*)(req)+1, 1, MSG_NOSIGNAL);

We have to cast req first since Posix.send () want's a (void*) Pointer and then we have to increment the casted Pointer by one (one Byte in this case) to get the next Byte.

This was the file I want to port to vala:
https://github.com/stephane/libmodbus/blob/v3.1.2/tests/unit-test-server.c#L190

And this is the working vala file:
https://github.com/zzeroo/modbus-vapi/blob/388c6de/tests/unit-test-server.vala#L212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment