Thread overview | |||||
---|---|---|---|---|---|
|
August 15, 2017 Issues with std.format template function | ||||
---|---|---|---|---|
| ||||
Hello! I'm having issues with the format function. My program is as follows: import std.format; import std.stdio; int main () { auto s = format!"%s is %s"("Pi", 3.14); writeln(s); // "Pi is 3.14"; } and when compiling with GDC, I'm getting this error: test.d:8: error: template instance format!"format is �i{" template '{ih�� ��� P�� @P� �N� P�� ' is not defined I do not know why. Any help would be much appreciated! Thank you all! |
August 15, 2017 Re: Issues with std.format template function | ||||
---|---|---|---|---|
| ||||
Posted in reply to LeqxLeqx | On Tuesday, 15 August 2017 at 04:44:25 UTC, LeqxLeqx wrote:
> Hello!
>
> I'm having issues with the format function.
>
> My program is as follows:
>
>
> import std.format;
> import std.stdio;
>
> int main ()
> {
>
> auto s = format!"%s is %s"("Pi", 3.14);
> writeln(s); // "Pi is 3.14";
>
> }
>
>
>
>
> and when compiling with GDC, I'm getting this error:
>
> test.d:8: error: template instance format!"format is �i{" template '{ih��
>
> ���
>
> P��
>
> @P� �N� P��
>
> ' is not defined
>
>
> I do not know why. Any help would be much appreciated!
>
>
> Thank you all!
GDC front-end is based on DMD 2.068.2 but the feature you use (format specifier as template parameter) is only there since DMD 2.075. The error comes from the fact that you read the online documentation which is not valid for GDC.
with GDC you can only does unchecked fmt:
`auto s = format("%s is %s", "Pi", 3.14);`
|
August 16, 2017 Re: Issues with std.format template function | ||||
---|---|---|---|---|
| ||||
Posted in reply to HyperParrow | On Tuesday, 15 August 2017 at 05:22:44 UTC, HyperParrow wrote:
> On Tuesday, 15 August 2017 at 04:44:25 UTC, LeqxLeqx wrote:
>> [...]
>
> GDC front-end is based on DMD 2.068.2 but the feature you use (format specifier as template parameter) is only there since DMD 2.075. The error comes from the fact that you read the online documentation which is not valid for GDC.
>
> with GDC you can only does unchecked fmt:
>
> `auto s = format("%s is %s", "Pi", 3.14);`
Well that explains it. Thanks for the info
|
Copyright © 1999-2021 by the D Language Foundation