Template instantiation fails on Linux, succeeds on Windows

Steven Schveighoffer schveiguy at yahoo.com
Fri May 18 13:57:32 UTC 2018

On 5/17/18 7:33 PM, Bastiaan Veelo wrote:
> On Thursday, 17 May 2018 at 23:18:32 UTC, Basile B. wrote:
>> On Thursday, 17 May 2018 at 22:07:46 UTC, Bastiaan Veelo wrote:
>>> Hi!
>>> The code in [1] compiles and runs flawlessly on Windows, but not on 
>>> Linux (neither run.dlang nor Travis docker image). Any idea what can 
>>> be done?
>> Hello. Yes, add `import core.stdc.stdarg;` in your module and it works.
>> I don't know why it's not required on windows, this is strange.
> Great! Thanks a lot, Basile!
> Seems there is room for improvement somewhere, a better error message at 
> the least.

Interestingly, the error was better before:


Tested on all compilers, up to 2.072.1, it results in:

onlineapp.d(1): Error: '__va_argsave_t' is not defined, perhaps you need 
to import core.vararg; ?
onlineapp.d(1): Error: function onlineapp.foo must import core.vararg to 
use variadic functions

In 2.072.2, it starts saying:

Error: undefined identifier '__va_list_tag'

The previous error was much better, but this to me is a huge code smell. 
Why do we have to import certain modules to use actual language 
features? Just to *define* a function, but not do anything inside it? 
I'd understand if this was a linker error, but surely the compiler can 
know to auto-import something, or at least spit out the proper extern(C) 

Note that your code works if I import core.vararg outside the function, 
you don't need core.stdc.stdarg. The import cannot be *inside* the function.


More information about the Digitalmars-d-learn mailing list