digitalmars.D - betterC error?
- makedgreatagain (9/9) Jun 12 2018 this very simple code can not build with betterC
- rikki cattermole (3/14) Jun 12 2018 Well yes, dynamic arrays require the GC and hence TypeInfo. Slices
- SrMordred (5/8) Jun 12 2018 is an dynamic array allocated with GC.
- Steven Schveighoffer (5/15) Jun 12 2018 Or use C malloc.
- SrMordred (3/7) Jun 12 2018 Indeed, i´m creating my own "toolkit" for betterC stuff like
- Walter Bright (3/4) Jun 12 2018 Need to declare main() like those C people do:
- makedgreatagain (6/10) Jun 12 2018 Thanks for all you help, the betteC is really useful and handy.
- Walter Bright (2/3) Jun 12 2018 That's great to hear!
this very simple code can not build with betterC void test(byte[] x){ } extern(C) int main(string[] args){ byte[] data = [0, 1]; test(data); return 0; }
Jun 12 2018
On 13/06/2018 12:13 AM, makedgreatagain wrote:this very simple code can not build with betterC void test(byte[] x){ } extern(C) int main(string[] args){ byte[] data = [0, 1]; test(data); return 0; }Well yes, dynamic arrays require the GC and hence TypeInfo. Slices don't, but that isn't a slice as it isn't from some random malloc'd memory.
Jun 12 2018
On Tuesday, 12 June 2018 at 12:29:17 UTC, rikki cattermole wrote:(...)this line:is an dynamic array allocated with GC. But if you declare as a static array likebyte[] data = [0, 1];than its not GC allocated.byte[2] data = [0, 1];
Jun 12 2018
On 6/12/18 10:18 AM, SrMordred wrote:On Tuesday, 12 June 2018 at 12:29:17 UTC, rikki cattermole wrote:Or use C malloc. We really should provide better tools to create arrays using C malloc (for those who want them). Like a betterC toolkit. -Steve(...)this line:is an dynamic array allocated with GC. But if you declare as a static array likebyte[] data = [0, 1];than its not GC allocated.byte[2] data = [0, 1];
Jun 12 2018
Or use C malloc. We really should provide better tools to create arrays using C malloc (for those who want them). Like a betterC toolkit. -SteveIndeed, i´m creating my own "toolkit" for betterC stuff like alloc!Type(length); (much safer than malloc!) and other utilities :)
Jun 12 2018
On 6/12/2018 5:13 AM, makedgreatagain wrote:extern(C) int main(string[] args){Need to declare main() like those C people do: extern (C) int main(int argc, char** argv){
Jun 12 2018
On Tuesday, 12 June 2018 at 18:41:57 UTC, Walter Bright wrote:On 6/12/2018 5:13 AM, makedgreatagain wrote:Thanks for all you help, the betteC is really useful and handy. I am try to made mobile app (right now IOS), seems Dan Olson 's great IOS work is stopped since 2 years ago. Hope the D community get better and better with more betterC Cross platform support.extern(C) int main(string[] args){Need to declare main() like those C people do: extern (C) int main(int argc, char** argv){
Jun 12 2018
On 6/12/2018 7:31 PM, makedgreatagain wrote:Thanks for all you help, the betteC is really useful and handy.That's great to hear!
Jun 12 2018