Thread overview
Template instantiation fails on Linux, succeeds on Windows
May 17, 2018
Bastiaan Veelo
May 17, 2018
Basile B.
May 17, 2018
Bastiaan Veelo
May 17, 2018
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?

errors:
Error: undefined identifier __va_list_tag
onlineapp.d(282): Error: template instance `onlineapp.SetFactory!byte` error instantiating
Error: undefined identifier __va_list_tag
onlineapp.d(288): Error: template instance `onlineapp.SetFactory!(Count)` error instantiating
Error: undefined identifier __va_list_tag
onlineapp.d(290): Error: template instance `onlineapp.SetFactory!char` error instantiating

SetFactory is defined on row 233, and it seems that the problem relates to the vararg opIndex.

[1] https://run.dlang.io/gist/6dcbe4e82846cbeb3bf478e92a2b6e6f
May 17, 2018
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.



May 17, 2018
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.
May 18, 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:

https://run.dlang.io/is/BgvH4w

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) declarations?

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.

-Steve