I think it's gone the other way in POSIX. Casting function pointers
to/from void * is required by dlsym and that's part of the XSI
extensions which are optional. However dlsym moved from XSI to Base and
now conversion between function pointers and void * is required to work
correctly.

That's all somewhat moot though. I don't think anyone should really
expect POSIX conformance from an embedded microcontroller :-)

Mike

On 07/05/2021 10:58, Philipp Klaus Krause wrote:
> Am 07.05.21 um 11:50 schrieb Павел Бельтюков:
>> Hi, Philipp
>>
>>     Using the normal C syntax.
>>     Function pointers are always 24 bits in the large model, while they are
>>     always 16 bits in the medium model.
>>     Thus, you can't just link files compiled using the medium model with
>>     files compiled using the large model.
>>
>>
>> OK, then how do I cast a function pointer to void * and backward?
>>
>> Best regards,
>> Paul Beltyukov
> You don't.
>
> The C standard (unlike POSIX¹) does not require C implementations to
> support casts between function pointers and void *, though this feature
> is mentioned as a common extension in the non-normative Annex J.5.7.
>
> If you need a type that can hold a pointer to anything (object or
> function), a union could be an option.
>
> Philipp
>
> ¹ I haven't checked the POSIX stanard now, but AFAIR, while POSIX still
> allows such casts, it is considered an obsolescent feature there.
>
>
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user



_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to