linkage of function with parameter from unnamed namespace

277 Views Asked by At
namespace { class A { } ; }

void foo ( A ) // _Z3fooN12_GLOBAL__N_11AE
{ ; } 

the function's symbol, apparently, would refer to the name of A, which is a member of uniquely named namespace (due to this).

what is the foo's linkage.?

1

There are 1 best solutions below

0
Brian Bi On BEST ANSWER

The function foo has external linkage since it is global and not declared static. The linkage of a function doesn't depend on the parameters.

The fact that A has internal linkage implies that it is not possible to call foo from another translation unit, since it is impossible to declare foo in the other translation unit, since there is no way to write the name of the type of foo's parameter. Any attempt to define A in another translation unit will actually define a different type.

Therefore, while the name foo technically has external linkage, it cannot actually be referred to by other translation units.