ERROR - "cannot implicitly convert expression (s) of type int[3u] to int*"
Chick Corea
chick.zcorea at gmail.com
Thu Jun 17 22:25:32 PDT 2010
[NOTE - sent twice as I was unsure that first attempt,
pre-subscription, was received.]
Working through the basics of D and running into simple problems that I
cannot solve, such as:
Error: cannot implicitly convert expression (s) of type int[3u] to int*
Error: cannot implicitly convert expression (a) of type int[] to int*
Those are the result of code that I pulled directly from the D v1 docs from
http://www.digitalmars.com/d/1.0/arrays.html
Specifically, the code is this.
int* p;
int[3] s;
int[] a;
p = s;
p = a;
I initially encountered this problem with the mark/release example code from
the D v2 docs - here:
http://www.digitalmars.com/d/2.0/memory.html
When I entered that code, it failed to compile. After debugging a few errors,
such as std/outofmemory.d being replaced by core.memory, I was left
w/ the same error as above but w/ void*/void[].
What is wrong w/ that ? How is it different from the docs that it does not
work ? More importantly, what rule is being violated so that we won't
encounter similar problems.
I am using dmd v1.062 for v1 code, and dmd v2.047, downloaded and
installed today onto a WinXP system.
$ dmd -v
Digital Mars D Compiler v1.062
Copyright (c) 1999-2010 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/1.0/index.html
Usage:
dmd files.d ... { -switch }
$ dmd -v # different path from above
Digital Mars D Compiler v2.047
Copyright (c) 1999-2010 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html
Usage:
dmd files.d ... { -switch }
Any help would be appreciated. D looks very promising for a real
application that I need to write, as if it could provide the performance
of C/C++ with the programmer-productivity of Perl/Python/etc.
But if the time that we save writing the app in D will be lost to debugging
simple problems like this then I won't have much of a choice.
Thanks in advance.
CHICKZ
More information about the Digitalmars-d-learn
mailing list