@@ -244,15 +244,15 @@ $(P
244
244
$(CCODE
245
245
#define ARRAY_LENGTH 17
246
246
int array[ARRAY_LENGTH];
247
- for (i = 0; i < ARRAY_LENGTH; i++)
247
+ for (size_t i = 0; i < ARRAY_LENGTH; i++)
248
248
func(array[i]);
249
249
)
250
250
251
251
or:
252
252
253
253
$(CCODE
254
254
int array[17];
255
- for (i = 0; i < sizeof(array) / sizeof(array[0]); i++)
255
+ for (size_t i = 0; i < sizeof(array) / sizeof(array[0]); i++)
256
256
func(array[i]);
257
257
)
258
258
@@ -666,11 +666,11 @@ struct ABC
666
666
align (1) int x; // x is byte aligned
667
667
align (4)
668
668
{
669
- ... // declarations in {} are dword aligned
669
+ ... // declarations in {} are 32-bit aligned
670
670
}
671
- align (2): // switch to word alignment from here on
671
+ align (2): // switch to 16-bit alignment from here on
672
672
673
- int y; // y is word aligned
673
+ int y; // y is 16-bit aligned
674
674
}
675
675
----------------------------
676
676
@@ -856,7 +856,7 @@ $(H2 $(LNAME2 arrayinit2, Array Initializations))
856
856
857
857
$(H4 The C Way)
858
858
859
- C initializes array by positional dependence. C99 fixes the issue:
859
+ C initializes arrays by positional dependence. C99 fixes the issue:
860
860
$(CCODE
861
861
int a[3] = { 3,2,1 };
862
862
int a[3] = { [2]=1, [0]=3, [1]=2 }; /* C99 designated initializer */
@@ -889,7 +889,8 @@ enum color { black, red, green }
889
889
int[3] c = [ black:3, green:2, red:5 ];
890
890
----------------------------
891
891
892
- Nested array initializations must be explicit:
892
+ Nested array initializations must be explicit and consistent with the
893
+ array types:
893
894
894
895
----------------------------
895
896
int[2][3] b = [ [2,3], [6,5], [3,4] ];
@@ -902,7 +903,8 @@ $(H2 $(LNAME2 stringlit, Escaped String Literals))
902
903
903
904
$(H4 The C Way)
904
905
905
- C has problems with the DOS file system because a \ is an escape in a string. To specifiy file c:\root\file.c:
906
+ C has problems with the DOS file system because a \ is an escape in a string.
907
+ To specifiy the file c:\root\file.c you would use:
906
908
$(CCODE
907
909
char file[] = "c:\\root\\file.c";
908
910
)
@@ -918,7 +920,7 @@ char quoteString[] = "\"[^\\\\]*(\\\\.[^\\\\]*)*\"";
918
920
$(H4 The D Way)
919
921
920
922
D has both C-style string literals which can use escaping,
921
- and WYSIWYG (what you see is what you get) raw strings
923
+ and WYSIWYG (what you see is what you get) raw strings,
922
924
usable with the `$(BACKTICK)foo$(BACKTICK)` and `r"bar"` syntax:
923
925
924
926
----------------------------
@@ -951,15 +953,15 @@ $(CCODE
951
953
#include <tchar.h>
952
954
tchar string[] = TEXT("hello");
953
955
)
954
- Furthermore, in praxis `wchar_t` is not usable in portable code as its size
956
+ Furthermore, in practice `wchar_t` is not usable in portable code as its size
955
957
is implementation dependent. On POSIX conforming machines it generally
956
- represents an UTF-32 codeunit, on Windows an UTF-16 codeunit . C11 introduced
958
+ represents an UTF-32 codeunit, on Windows an UTF-16 code unit . C11 introduced
957
959
C++11 types char16_t and char32_t to overcome this issue.
958
960
959
961
$(H4 The D Way)
960
962
961
963
The type of a string is determined by semantic analysis, so there is no need
962
- to wrap strings in a macro call. Alternatively if type inference is used the
964
+ to wrap strings in a macro call. Alternatively, if type inference is used, the
963
965
string can have a `c`, `w` or `d` suffix, representing UTF-8,
964
966
UTF-16 and UTF-32 encoding, respectively. If no suffix is used the type is
965
967
inferred to be a UTF-8 string:
@@ -1098,7 +1100,7 @@ if (h != Handle.init)
1098
1100
...
1099
1101
-----------------------------
1100
1102
1101
- There 's only one name to remember: $(D Handle).
1103
+ Now there 's only one name to remember: $(D Handle).
1102
1104
1103
1105
<hr>$(COMMENT ============================================ )
1104
1106
$(H2 $(LNAME2 structcmp, Comparing structs))
0 commit comments