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

Re: RFC: Support non-standard extension (call via casted function pointer)



On 25.01.2016 23:07, Andreas Schwab wrote:
> Michael Karcher <debian@mkarcher.dialup.fu-berlin.de> writes:
>> but it fixes the return type to some pointer type.
> Why does it do that?
Please help me understand why the sentence before the sentence you
quoted is not an answer to your question:

| This is because its internal Cmm (a C-- dialect) to C compiler needs
| to declare external functions (no varargs) without fixing the type.

If your question is why ghc fixes the return type: It's because you
*can't* (forward-)declare a function without fixing the return type.

If your question is why ghc needs to declare the function without fixing
the type: I guess this is because the semantics of Cmm do not attach types
to function symbols. You can assign them to (untyped) pointers or call
them directly or via those pointers. Only at the time of call you have
to specify the type.

If your question is why they opted to use some pointer type: Most likely the
chose a pointer type to obtain a return type whose size is a native machine
word. intptr_t is not as widely available as plain pointers.

Regards,
  Michael Karcher


Reply to: