Difference (last change)
(
Author,
normal page display)
Added: 2a3
Changed: 15c16
Changed: 36c37,38
| Table of contents of this page | |
|
|
's.length' is not an lvalue
Problem code:
| void main()
{
char[] s;
s.length++;
} |
|
|
Change
to
See also NG:D/25540, NG:D/25486, NG:D/25619, NG:digitalmars.D/10823, NG:digitalmars.D.bugs/1882, http://www.eskimo.com/~scs/C-faq/s3.html, DigitalMars:d/archives/10070.html.
Conflicting Symbols
Problem code:
| import std.ctype;
import std.string;
void main()
{
char[] s = "some string";
s = toupper(s);
printf("%.*s\n", s);
} |
|
|
Error message:
| c:\dmd\bin\..\src\phobos\std\string.d(502): function toupper
conflicts with ctype.toupper at c:\dmd\bin\..\src\phobos\std\ctype.d(36) |
|
|
There are multiple solutions. The simplest is to change
to
| s = std.string.toupper(s); |
|
|
See also NG:D/26519.
A struct is not a valid initializer for an array
Problem code:
| int[] data = { 17, 23, 42, 69, 105, 666 }; |
|
|
Arrays are initialized using square brackets []
| int[] data = [ 17, 23, 42, 69, 105, 666 ]; |
|
|
Structs are initialized using braces {}
| struct Foo
{
int A;
char[] B;
}
const Foo X = {1, "abc"}; |
|
|
To combine them:
| struct Foo
{
int A;
char[] B;
}
const Foo[] X = [ {1, "abc" },
{4, "xyzzy" }
]; |
|
|