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

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Feb 14 15:31:23 CET 2011

Some addenda...

On 14 Feb 2011, at 15:06, Jonas Maebe wrote:

> A "weakexternal" declaration by itself is not a reference (weak/ 
> undefined or not), neither at the Pascal, C nor at the assembler/ 
> object file level.

This is not correct for all platforms and for all declarations. It's  
true for function declarations in C, but not for data declarations in  
C when targetting ELF platforms (there a "weak external" declaration  
in a C file does result in a reference from the object file's symbol  
table). It's also not correct for the assembler/object file level  
(also results in a reference).

>> which - if it doesn't exist - points to some other external  
>> reference. A weak procedure would be almost the same, you just add  
>> the default reference as code explicitly
> It's the same as the difference between these two declarations in C:
> int SayHello(void) __attribute__((weak))
> {
>  ...
> }

This actually doesn't work. It seems gcc only supports weak  
definitions of data symbols. For functions, you have to say that it's  
weak when (externally or not) declaring it, it doesn't work anymore as  
part of the definition:

1) for data, this works:

int global __attribute__((weak)) = 999;

2) for code, only this works:

int SayHello() __attribute__((weak));

int SayHello() {

I don't see why we wouldn't support them both for code and data in FPC  


More information about the fpc-devel mailing list