www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - alias symbols in object files

reply "John Colvin" <john.loughran.colvin gmail.com> writes:
test.d:

extern (C):
void foo(){}
alias foo bar;

$dmd -c test.d

$nm test.o
0000000000000000 t
0000000000000000 D _D11test12__ModuleInfoZ
                  w _d_dso_registry
                  U _Dmodule_ref
0000000000000000 T foo


Surely the aliased symbol should appear in the object file, or am 
I missing something?
Apr 21 2013
next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Sunday, 21 April 2013 at 18:54:27 UTC, John Colvin wrote:
 test.d:

 extern (C):
 void foo(){}
 alias foo bar;

 $dmd -c test.d

 $nm test.o
 0000000000000000 t
 0000000000000000 D _D11test12__ModuleInfoZ
                  w _d_dso_registry
                  U _Dmodule_ref
 0000000000000000 T foo


 Surely the aliased symbol should appear in the object file, or 
 am I missing something?
Just to avoid any confusion for non-linux guys: nm is a linux utility for listing the symbols in an object file.
Apr 21 2013
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 4/21/13, John Colvin <john.loughran.colvin gmail.com> wrote:
 Surely the aliased symbol should appear in the object file, or am
 I missing something?
Aliases are a purely compile-time feature. Wherever they're used it's as if the compiler rewrote the alias with the aliased symbol.
Apr 21 2013
prev sibling parent reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Sunday, 21 April 2013 at 18:54:27 UTC, John Colvin wrote:
 Surely the aliased symbol should appear in the object file, or 
 am I missing something?
What would you expect it to look like in the object file? A duplicate of the foo function?
Apr 21 2013
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Sunday, 21 April 2013 at 19:22:27 UTC, Peter Alexander wrote:
 On Sunday, 21 April 2013 at 18:54:27 UTC, John Colvin wrote:
 Surely the aliased symbol should appear in the object file, or 
 am I missing something?
What would you expect it to look like in the object file? A duplicate of the foo function?
Something like that, yes. I have a templated function and need particular instantiations of it in a library. If aliases cannot be used for this, I suppose the most reasonable option is to write wrapper functions.
Apr 21 2013