string object won't compile

askjfbd icadraic9 at gmail.com
Mon Mar 5 23:34:50 UTC 2018


Someone please tell me how, for I am a newbie and don't know any 
solutions even to this very simple problem. As I learned dlang 
using the Dlang tour page, I stuck at the alias & Strings page. I 
have tried to compile the following simple code many times but 
still get the same error both from dmd and gdc. They both say that
<----------------------------------------------------
string.d:9:9: error: module string is used as a type
   string str = "This is a test.";
---------------------------------------------------->
whenever I tried compiling this code below
<------------------------------------------
import std.stdio;
import std.string;

void main()
{
     //alias string = immutable(char)[];
     string str = "This is a test.";
}
------------------------------------------->
However, when I uncomment the alias~ line above,
both dmd and gdc can compile the code. I thought
that the string object is already defined in the
package or somewhere beforehand, but am I wrong?



More information about the Digitalmars-d-learn mailing list