Lesson/Example please

Richard Laager rlaager at wiktel.com
Mon Mar 15 19:19:46 UTC 2021


On 3/15/21 2:06 PM, Richard Laager via devel wrote:
> On 3/14/21 11:25 PM, Hal Murray via devel wrote:
>> Can anybody give me a pointer to code that does this?  Or steer me in the
>> right direction, or ...
>>
>> There is a recursive tangle of struct needs function and function 
>> needs struct, but the function only needs a pointer to the struct so I 
>> think that should work.
> 
> Personally, I'd probably typedef the struct:
> 
> typedef struct _NtpSomething NtpSomething;
> struct _NtpSomething
> {
>      void (*some_func) (NtpSomething *);
> }
> 
> 
> If you want to typedef the function too, something like this should work:
> 
> typedef struct _NtpSomething NtpSomething;
> 
> typedef void (*NtpSomeFunc)(NtpSomething *);

I failed to edit this after copying-and-pasting. Correction:

struct _NtpSomething
{
      NtpSomeFunc (NtpSomething *);
}

-- 
Richard


More information about the devel mailing list