Re: C library

Bernd Paysan <[email protected]> Fri, 29 Sep 2023 04:17:28 +0200
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <2627299.k3LOHGUjKi@liubei>
Am Donnerstag, 28. September 2023, 20:00:34 CEST schrieb Mario Beaulieu via 
Gforth discussion and announcements:
> c-function mosquitto_new   mosquittoNew a n void -- "What do I put here?"

This should be:

c-function mosquittoNew mosquitto_new s n a -- a

The order of names (Forth name first, C name second) matters, and for the 
paramenters: whatever address it is, it should be an a type, i.e. whenever the 
C programmer writes a * at the end of the type, it is an a.  Unless of course 
if it is a const char *, i.e. a string, then it is more comfortable to pass a 
Forth string to C, and use the s type, so you can call

s" my id" 1 callback-object mosquittoNew

and the s type constructs a zero terminated C string out of that Forth string.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o id: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
https://net2o.de/
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEERJ1NDqPQRwYnwBjr9y2Uk5MtoGcFAmUWM7gACgkQ9y2Uk5Mt
oGcEMg/9Ff34VvhgrUxe5hyU8vWSAChyYDXzZKIW9nXOxGtzz7mCrKq7Jhml+TK3
JV4ombTeXAtKYnr/qrS+sBwX9EkRjxixLAvFjTmdr0sg3T08pBeHE+PZB1rEGXFN
vYxfP6Rp9CMq0swy5WFoSEkDInooukV+3oPsyVbUbfIHByx/QQKnl9renRPBWooq
j76FhI0f2T4idATgkk7zrnwz8m6QMm5fkBU0Ist/5zltU2H8FzvBqyfcE6Yv6dKa
iflmWz2GUUGIkoSKR2pc5TxWGDBUi4CMVlaA/C1u983Ta1tgjvYlUp8loyWXJmdS
HoezwbLbxpveNvmH82uk3j5amOUJ6jNEnbU+OB/0eVDntSVrli8I0010bGjD4hUp
3u4LfojE7KCxMyUwK2TYNitKxIPEqkfhXhVtBmhWur008rkujCwb8ZHVnxyTHXJ+
/PPIho28QGrJ0Aft81IZg2raneDlgFzDIWnQumkEQb5LCidLLEiHqQqNuJnIXo8i
XaWTdUJBIxICp03ABJEHQ0rNLRMIS/rlFJxc6i3pyR+yyXO0tF/MXSOf/snvEhwq
c8si5lFzciFpmlynOEachprqRojcYpQXIzn1BDvVSRXWwlkkVaihAA4RvCGxPz6S
YWD/YE05Ie1/p+cmf76c4VfCA3hyPTXjJBqcJYOJPgfWuLIPBAs=
=r0Hx
-----END PGP SIGNATURE-----