Re: Strange behavior in callbacks

Rene Hartmann <[email protected]>
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <[email protected]>
Reepca Russelstein wrote:
> On Tue, Mar 13, 2018 at 11:59 AM, Reepca Russelstein
> <[email protected]> wrote:
>> Trying to get some c callbacks working and encountering some strange behavior...
>>
>> c-library genericCallback
>>      \c void genericCallback(void (*tocall)(void))
>>      \c {
>>      \c    tocall();
>>      \c }
>>      c-function genericCallback genericCallback a -- void
>>      c-callback blankCallback -- void
>> end-c-library
>>
>>
>> :noname   .s s" 1 2 + ." evaluate ; blankCallback genericCallback
>>
>>
>> That produces
>>
>> <-21965655376>
>> uncaught exception: Stack underflow
>>
>>
>> I initially thought to have the signature of genericCallback be func
>> -- void, but swig kept calling them addresses instead. Also it
>> produced the same result.
>>
>> Looking at the generated wrapper code, I see that a new stackpointers
>> variable is created and used. It seems that whatever stack checking is
>> happening isn't taking this into account, coming to some incorrect
>> conclusions instead.
>>
>> I came across this trying to evaluate input in glutIdleFunc so that I
>> could keep making changes while the program is running. Any advice on
>> how to make this use case work, that doesn't involve "just don't use
>> glut" (I'd love to be able to take it...)?
>>
>> Thanks.
> 
> I should specify, I'm using the latest git from savannah.
> 
> 

I tried GForth callbacks a while ago and couldn't get them to work either.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.