Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extern for aliased template instantiation #19612

Open
dlangBugzillaToGithub opened this issue Aug 22, 2019 · 0 comments
Open

extern for aliased template instantiation #19612

dlangBugzillaToGithub opened this issue Aug 22, 2019 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

a11e99z reported this on 2019-08-22T15:08:26Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=20153

Description

I want to export non-mangled instantiated through alias template function.
it can be useful for WASM, DLLs/SharedLibs and etc.
but alias for template instatiation is ignored.
pragma mangle to alias is ignored too.

-----------------------------------
void main() {}

export:                  // EXPORTed
extern (C):              // NO MANGLE but IGNORED
public:

void fun( Char )( Char* ) { }

pragma (mangle, "func")  // IGNORED
alias func = fun!char;
pragma( msg, func.mangleof );

pragma (mangle, "funw")  // IGNORED
alias funw = fun!wchar;
pragma( msg, funw.mangleof );

------------ OUTPUT -----------------------
_D9onlineapp__T3funTaZQhUNaNbNiNfPaZv
_D9onlineapp__T3funTuZQhUNaNbNiNfPuZv


current workaround: wrap template funcs to non-template.

possible solution:
if "alias" locates in non-mangle block (extern(C) for example) then do not mangle name and check that no others entities with same name exists in current context.
OR/AND
make "pragma mangle" working for alias-es too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant