Forbidden file names?
Brian
bcallah at openbsd.org
Sun Mar 14 20:47:00 UTC 2021
Hello --
Apologies if this is answered somewhere in the documentation.
I was trying out the sample code on the dlang.org home page.
When I got to the "Sort an Array at Compile-Time" example, I
saved it on my machine as sort.d. When I tried to build sort.d,
the compile failed. But when I renamed sort.d to anything else
(e.g., array.d), the compilation was fine.
I am wondering if this is expected.
Thanks! Terminal output below explaining the above.
~Brian
/home/brian/d $ cat sort.d
void main()
{
import std.algorithm, std.conv, std.stdio;
"Starting program".writeln;
// Sort a constant declaration at Compile-Time
enum a = [ 3, 1, 2, 4, 0 ];
static immutable b = sort(a);
// Print the result _during_ compilation
pragma(msg, text("Finished compilation: ", b));
}
/home/brian/d $ dmd sort.d
sort.d(9): Error: function expected before `()`, not `module
sort` of type `void`
sort.d(12): while evaluating `pragma(msg, text(T...)(T
args) if (T.length > 0)("Finished compilation: ", b))`
/home/brian/d $ mv sort.d array.d
/home/brian/d $ dmd array.d
Finished compilation: immutable(SortedRange!(int[], "a < b",
SortedRangeOptions.assumeSorted))([0, 1, 2, 3, 4])
More information about the Digitalmars-d-learn
mailing list