microsoft / hlsl-specs

HLSL Specifications
MIT License
116 stars 29 forks source link

Add Linkage section #249

Closed hekota closed 2 months ago

hekota commented 3 months ago

Create chapter file for Declarations and add section about linkage. Enumerate the language defaults and where it is implementation dependent. Add empty chapter file for Statements to preserve the chapter ordering.

hekota commented 2 months ago

In the cases of external and internal linkage there's also a property where a declaration inherits the linkage of its encompassing declaration. For example:

namespace PublicStuff {
  void Fn(int); // external linkage

  class Obj {
    void MemberFn(); // external linkage
  }; // external linkage
}

namespace {
  void Fn(int); // internal linkage

  class Obj {
    void MemberFn(); // internal linkage
  }; // internal linkage
}

DXC currently does not support unnamed namespaces, that's why I did not include it here.

This isn't true for all declarations. For example declarations in function-scope and scopes that derive from function-scope are always no-linkage unless they are static.

I believe this is described in the No Linkage section under the term block-scope. I can add more details to that section to make it clearer.