[fpc-devel] Proposal: Supporting initial references for weakexternal

Paul Ishenin ip at kmiac.ru
Wed Jan 12 07:40:18 CET 2011

12.01.2011 13:21, Jeppe Johansen wrote:
>> a) NoHandler must have the same arguments and calling convention as
>> TestProc?
> With this solution, no. This uses only symbol names

This I don't understand. What happen when I call

DoSomething(1, 'test');

But DoSomething is not resolved and instead 
HandleDoSomethingUnresolved() is called? Is there a chance to access my 
arguments from that handler or no?

What happen if I pass some argument by reference and expect a result or 
do a function call:

Value := CallSomething(); // What Value equal to if CallSomething is not 

>> b) What happen if NoHandler is not found?
> Then TestProc cannot be resolved to any symbol, and will generate a weak
> undefined reference. Eg. it won't complain about an undefined reference

I don't see where you reference the "weakinitial" symbol in your patch 
that's why I'm asking this question. If NoHandler is not referenced it 
will be stripped away during the linking process?

Generally I want to have an ability to handle a case where I call an 
unresolved symbol but I want to be sure that I receive arguments and my 
handler will not be striped from the executable.

I'd better suggest the next syntax:

procedure NoHandler;

procedure TestProc; weakexternal name 'TestProc' set NoHandler;

In this case I'm sure that:
1. NoHandler is a valid identifier which points to a procedure.
2. I can check that NoHandler has compatible with TestProc definition.
3. I can reference NoHandler so it will not be removed away from the 

Although I may be just don't understand your proposal.

Best regards,
Paul Ishenin

More information about the fpc-devel mailing list