ERROR - "cannot implicitly convert expression (s) of type int[3u] to int*"
ellery-newcomer at utulsa.edu
Thu Jun 17 23:35:42 PDT 2010
On 06/18/2010 12:25 AM, Chick Corea wrote:
> [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
> Specifically, the code is this.
> int* p;
> int s;
> int a;
> p = s;
> p = a;
> I initially encountered this problem with the mark/release example code from
> the D v2 docs - here:
> 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.
Rather simple. The docs are wrong (although I don't doubt that at some
point in D's history the above was valid). Use
p = s.ptr;
p = s;
because arrays are not not not not not not not pointers. They're more of a
> 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.
Yup. That's the jingle.
> 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.
Hang in there. In my experience, picking up a new language is always a
frustrating experience. I think you'll find that D is worth it, though.
> Thanks in advance.
More information about the Digitalmars-d-learn