On 15.11.2013 08:02, Benjamin Thaut wrote:
Am 15.11.2013 00:38, schrieb Rainer Schuetze:
Maybe. Another rule might be that only the declarations actually
annotated with "export" gets exported with the instantiation, so you
could add "export" to the whole class or only some declaraations.
I don't think this is a good idea. It should be possible to put
"export:" on top of a file and just export everything. If you limit it
to decelerations the following would work:
export __gshared int g_var;
but the following wouldn't:
export __gshared int g_var = 0;
Although it would really produce equivalent code.
I don't follow. What does this have to do with template instances?
I was referring to your example where you wanted to export just one
symbol from a template class.
compiling c and d as single files will silently generate different code,
because when compiling d, the export alias is never seen.
(this cannot happen with standard variables, only when declared multiple
times, but differently, with extern(C/C++/System)).
And do you already have a idea how we could work around this problem?
It might be possible to produce some linker errors: e.g. the dllimport
version drags in the __imp_var symbol that also provides a _var
definition record that produces some link error (e.g. by referring to a
non-existing symbol). If it links to a non-dllimport version that
actually refers to _var, it bails out.
Generated COMDAT records that define the _var symbol aswell might cause
problems here, though, because the current COMDAT selection strategy is
"pick any".