[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C library
From: |
francois.gallois.pro |
Subject: |
Re: C library |
Date: |
Thu, 28 Sep 2023 21:38:35 +0200 (GMT+02:00) |
You will simply get an "a" for the address, from which you can then extract the
various members of the struct.
The wrapper automatically generated through the fork of SWIG coming with Gforth
can handle creating the utility words to access the members of the struct (see
https://gforth.org/manual/Automated-interface-generation-using-SWIG.html).
28 sept. 2023 20:30:29 Mark J. Reed <markjreed@gmail.com>:
> All Forth really cares about is the size of the returned value. I'd expect
> a pointer to have type "a" (address).
>
> On Thu, Sep 28, 2023 at 2:01 PM Mario Beaulieu via Gforth discussion and
> announcements <gforth@gnu.org> wrote:
>
>> Hi,
>>
>> I'm trying to use a C library to handle mqtt messages from GForth. I use
>> Mosquitto as a message broker (on a Raspberry Pi 3).
>>
>> The header file for mosquito can be found here:
>> https://mosquitto.org/api/files/mosquitto-h.html
>>
>> I get the information about GForth’s C Interface from
>> https://gforth.org/manual/C-Interface.html
>>
>>
>> At the moment, I'm struggling on the function ‘mosquitto_new’. More
>> precisely, my issue is that this function returns a pointer to a struct («
>> Pointer to a struct mosquitto on success »), which I can't figure out how
>> to code.
>>
>> Here's my code:
>> *********
>> c-library libmosquitto
>>
>> \c #include <sys/types.h>
>> \c #include <mosquitto.h>
>>
>> c-function mosquitto_lib_init mosquittoLibInit
>> -- void
>> c-function mosquitto_connect mosquittoConnect a a n n -- void
>> c-function mosquitto_subscribe mosquittoSubscribe a n a a -- void
>> c-function mosquitto_loop mosquittoLoop a n n --
>> void
>>
>> c-function mosquitto_new mosquittoNew a n void -- "What do I put here?"
>>
>> end-c-library
>> *******
>>
>> I get an « Invalid name argument » error for every type I try.
>>
>> Note that I'm not a C programmer, so I might be struggling with something
>> obvious.
>>
>> Any help will be appreciated
>>
>> Thank you
>>
>> Mario
>>
>> Envoyé de mon iPad
>
>
>
> --
> Mark J. Reed <markjreed@gmail.com>