www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - string not aliased

reply chbrosso free.fr (Charles Brossollet) writes:
Hi all,

I'm a complete newbie to D, and tried the examples on the Wikipedia
page. the example 2 shows a main function like this:

int main(string[] args)   // string is a type alias for const(char)[]

But, I get this error on compile:
hello.d:3: Error: identifier 'string' is not defined
hello.d:3: Error: string is used as a type
hello.d:3: function hello.main parameters must be main() or
main(char[][] args)

Is the guy writing the example wrong? Or is it my environment? (gdc
0.23, on Mac OSX 10.4)

Thanks,

-- 
Charles
Aug 15 2007
next sibling parent reply Regan Heath <regan netmail.co.nz> writes:
Charles Brossollet wrote:
 Hi all,
 
 I'm a complete newbie to D, and tried the examples on the Wikipedia
 page. the example 2 shows a main function like this:
 
 int main(string[] args)   // string is a type alias for const(char)[]
 
 But, I get this error on compile:
 hello.d:3: Error: identifier 'string' is not defined
 hello.d:3: Error: string is used as a type
 hello.d:3: function hello.main parameters must be main() or
 main(char[][] args)
 
 Is the guy writing the example wrong? Or is it my environment? (gdc
 0.23, on Mac OSX 10.4)

The string alias was added in DMD 1.016: http://www.digitalmars.com/d/1.0/changelog.html#new1_016 GDC 0.21 was based on DMD 1.000, but I have no idea what GDC 0.23 is based on as I cannot see that info on the GDC page. I suspect it's still based on DMD 1.000 and therefore has no aliases. However, the aliases are defined in phobos and I suspect if you grab the latest phobos source and build it you will solve your problem. Regan
Aug 15 2007
next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Regan Heath wrote:

 The string alias was added in DMD 1.016:
 http://www.digitalmars.com/d/1.0/changelog.html#new1_016
 
 GDC 0.21 was based on DMD 1.000, but I have no idea what GDC 0.23 is 
 based on as I cannot see that info on the GDC page.
 
 I suspect it's still based on DMD 1.000 and therefore has no aliases.

GDC 0.23 is based on DMD 1.007, see http://gdcmac.sf.net --anders
Aug 15 2007
parent Regan Heath <regan netmail.co.nz> writes:
Anders F Björklund wrote:
 Regan Heath wrote:
 
 The string alias was added in DMD 1.016:
 http://www.digitalmars.com/d/1.0/changelog.html#new1_016

 GDC 0.21 was based on DMD 1.000, but I have no idea what GDC 0.23 is 
 based on as I cannot see that info on the GDC page.

 I suspect it's still based on DMD 1.000 and therefore has no aliases.

GDC 0.23 is based on DMD 1.007, see http://gdcmac.sf.net

Ahh, thanks. I was looking here: http://dgcc.sourceforge.net/#doc I saw the link to gdcmac and gdcwin but I didn't follow them. Regan
Aug 15 2007
prev sibling parent chbrosso free.fr (Charles Brossollet) writes:
Regan Heath <regan netmail.co.nz> wrote:

 Charles Brossollet wrote:
 Hi all,
 
 I'm a complete newbie to D, and tried the examples on the Wikipedia
 page. the example 2 shows a main function like this:
 
 int main(string[] args)   // string is a type alias for const(char)[]
 
 But, I get this error on compile:
 hello.d:3: Error: identifier 'string' is not defined
 hello.d:3: Error: string is used as a type
 hello.d:3: function hello.main parameters must be main() or
 main(char[][] args)
 
 Is the guy writing the example wrong? Or is it my environment? (gdc
 0.23, on Mac OSX 10.4)

The string alias was added in DMD 1.016: http://www.digitalmars.com/d/1.0/changelog.html#new1_016 GDC 0.21 was based on DMD 1.000, but I have no idea what GDC 0.23 is based on as I cannot see that info on the GDC page. I suspect it's still based on DMD 1.000 and therefore has no aliases. However, the aliases are defined in phobos and I suspect if you grab the latest phobos source and build it you will solve your problem.

GDC 0.23 is based on DMD 1.007, so that explains my problem. Thank you very much, -- Charles
Aug 15 2007
prev sibling next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Charles Brossollet wrote:

 I'm a complete newbie to D, and tried the examples on the Wikipedia
 page. the example 2 shows a main function like this:
 
 int main(string[] args)   // string is a type alias for const(char)[]
 
 But, I get this error on compile:
 hello.d:3: Error: identifier 'string' is not defined
 hello.d:3: Error: string is used as a type
 hello.d:3: function hello.main parameters must be main() or
 main(char[][] args)
 
 Is the guy writing the example wrong? Or is it my environment? (gdc
 0.23, on Mac OSX 10.4)

The example is using D 2.0, while GDC supports D 1.0 at the moment. (the language was split into two different versions a while ago...) int main(char[][] args) --anders
Aug 15 2007
parent reply Regan Heath <regan netmail.co.nz> writes:
Anders F Björklund wrote:
 Charles Brossollet wrote:
 
 I'm a complete newbie to D, and tried the examples on the Wikipedia
 page. the example 2 shows a main function like this:

 int main(string[] args)   // string is a type alias for const(char)[]

 But, I get this error on compile:
 hello.d:3: Error: identifier 'string' is not defined
 hello.d:3: Error: string is used as a type
 hello.d:3: function hello.main parameters must be main() or
 main(char[][] args)

 Is the guy writing the example wrong? Or is it my environment? (gdc
 0.23, on Mac OSX 10.4)

The example is using D 2.0, while GDC supports D 1.0 at the moment. (the language was split into two different versions a while ago...) int main(char[][] args)

Technically I guess it's D 1.016 or D 2.0 code. Am I correct about rebuilding phobos (in my reply to the OP) or will that fail utterly? Regan
Aug 15 2007
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Regan Heath wrote:

 The example is using D 2.0, while GDC supports D 1.0 at the moment.
 (the language was split into two different versions a while ago...)

 int main(char[][] args)

Technically I guess it's D 1.016 or D 2.0 code. Am I correct about rebuilding phobos (in my reply to the OP) or will that fail utterly?

You are right, it'll probably be fixed in GDC 0.24 then. (DMD 1.018) The aliases can probably be added to the object.d manually meanwhile alias char[] string; alias wchar[] wstring; alias dchar[] dstring; --anders
Aug 15 2007
prev sibling next sibling parent Witold Baryluk <baryluk smp.if.uj.edu.pl> writes:
Dnia Wed, 15 Aug 2007 18:24:19 +0200
chbrosso free.fr (Charles Brossollet) napisa=B3/a:

 Hi all,
=20
 I'm a complete newbie to D, and tried the examples on the Wikipedia
 page. the example 2 shows a main function like this:
=20
 int main(string[] args)   // string is a type alias for const(char)[]
=20
 But, I get this error on compile:
 hello.d:3: Error: identifier 'string' is not defined
 hello.d:3: Error: string is used as a type
 hello.d:3: function hello.main parameters must be main() or
 main(char[][] args)
=20
 Is the guy writing the example wrong? Or is it my environment? (gdc
 0.23, on Mac OSX 10.4)

This is example of D 2, code. Who the hell published this on Wikipedia? use: int main(char[][] args) { ... } or put "alias char[] string;" before main --=20 Witold Baryluk MAIL: baryluk smp.if.uj.edu.pl, baryluk mpi.int.pl JID: movax jabber.autocom.pl
Aug 15 2007
prev sibling next sibling parent Carlos Santander <csantander619 gmail.com> writes:
Charles Brossollet escribió:
 Hi all,
 
 I'm a complete newbie to D, and tried the examples on the Wikipedia
 page. the example 2 shows a main function like this:
 
 int main(string[] args)   // string is a type alias for const(char)[]
 
 But, I get this error on compile:
 hello.d:3: Error: identifier 'string' is not defined
 hello.d:3: Error: string is used as a type
 hello.d:3: function hello.main parameters must be main() or
 main(char[][] args)
 
 Is the guy writing the example wrong? Or is it my environment? (gdc
 0.23, on Mac OSX 10.4)
 
 Thanks,
 

string was added in DMD 1.016, which corresponds to GDC SVN revision 134. GDC 0.23 is only up to DMD 1.007, so get the latest GDC. You can find instructions in http://dsource.org/projects/tango/wiki/UnixInstallGdc, down to the "GDC Installation from source" section. -- Carlos Santander Bernal
Aug 15 2007
prev sibling parent Tomas Lindquist Olsen <tomas famolsen.dk> writes:
Charles Brossollet wrote:

 Hi all,
 
 I'm a complete newbie to D, and tried the examples on the Wikipedia
 page. the example 2 shows a main function like this:
 
 int main(string[] args)   // string is a type alias for const(char)[]
 
 But, I get this error on compile:
 hello.d:3: Error: identifier 'string' is not defined
 hello.d:3: Error: string is used as a type
 hello.d:3: function hello.main parameters must be main() or
 main(char[][] args)
 
 Is the guy writing the example wrong? Or is it my environment? (gdc
 0.23, on Mac OSX 10.4)
 
 Thanks,
 

imho), and with gdc 0.23 being 1.007 it's not availble, seems like someone was a bit enthusiastic updating the wikipedia pages.
Aug 15 2007