gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C library


From: Mark J. Reed
Subject: Re: C library
Date: Thu, 28 Sep 2023 17:08:55 -0400

You should be replying to the list, not just me. I thought you were. We've
exhausted my knowledge at this point.

On Thu, Sep 28, 2023 at 15:38 Mario Beaulieu <mariobeaulieu21@yahoo.ca>
wrote:

> You are absolutely right! Thank you.
>
> That did not solve the problem though, but it's important that I know
> that. Thanks!
>
> Mario
>
> Envoyé de mon iPad
>
> Le 28 sept. 2023 à 15:07, Mark J. Reed <markjreed@gmail.com> a écrit :
>
> 
>
> You seem to have the names backward. The name you want to give the Forth
> word comes first, then the C function name.
>
> On Thu, Sep 28, 2023 at 14:39 Mario Beaulieu <mariobeaulieu21@yahoo.ca>
> wrote:
>
>> Hi,
>>
>> Thank you. I tried but I get an error (invalid name argument).
>>
>> Mario
>>
>> Envoyé de mon iPad
>>
>> Le 28 sept. 2023 à 14:30, Mark J. Reed <markjreed@gmail.com> a écrit :
>>
>> 
>>
>> 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>
>>
>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]