home bbs files messages ]

Just a sample of the Echomail archive

COMPLANC:

<< oldest | < older | list | newer > | newest >> ]

 Message 242,727 of 243,097 
 David Brown to Chris M. Thomasson 
 Re: function pointer question 
 03 Jan 26 13:55:01 
 
From: david.brown@hesbynett.no

On 02/01/2026 23:18, Chris M. Thomasson wrote:
> On 1/2/2026 1:52 PM, Kaz Kylheku wrote:
>> On 2026-01-02, Michael Sanders  wrote:
>>> On Fri, 2 Jan 2026 17:48:16 -0000 (UTC), Kaz Kylheku wrote:
>>>
>>>> On 2026-01-02, Michael Sanders  wrote:
>>>>> B: because every function must have a return type
>>>>>     *including function pointers*?
>>>>
>>>> What it is you think type is, in the context of C?
>>>>
>>>> Does type survive into run-time?
>>>>
>>>> If a function pointer is missing type information about return type,
>>>> and
>>>> that function pointer is needed for expressing a function call, where
>>>> does the compiler get the type from?
>>>
>>> Its void that's throwing me Kaz. I'm not sure what to think when
>>> it comes to void pointers.
>>
>> Because you teleported here from 1985.
>
> [...]
>
> One note, void* cannot hold a function pointer without getting undefined
> or implementation-defined behavior.
>

Kaz mentioned several types that "void *" is a generic /object/ pointer.
  Functions are not objects - pointers to functions are completely
different from pointers to objects.  You can't mix them without "I know
what I am doing" explicit casts, with non-portable behaviour and a
serious risk of UB.

> typedef void (*generic_func_ptr)(void)

There is no generic function pointer type equivalent to "void *" - you
are always going to need casts when converting between different pointer
types.  And you /really/ need to make sure you convert to exactly the
correct type before calling the pointed-to function.  But the definition
you gave here is commonly used when people want to have generic function
pointers.

--- SoupGate-Win32 v1.05
 * Origin: you cannot sedate... all the things you hate (1:229/2)

<< oldest | < older | list | newer > | newest >> ]


(c) 1994,  bbs@darkrealms.ca