Thread overview
betterC error?
Jun 12, 2018
makedgreatagain
Jun 12, 2018
rikki cattermole
Jun 12, 2018
SrMordred
Jun 12, 2018
SrMordred
Jun 12, 2018
Walter Bright
Jun 13, 2018
makedgreatagain
Jun 13, 2018
Walter Bright
June 12, 2018
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;
}

June 13, 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.
June 12, 2018
On Tuesday, 12 June 2018 at 12:29:17 UTC, rikki cattermole wrote:
> (...)

this line:
>>> byte[] data = [0, 1];
is an dynamic array allocated with GC.
But if you declare as a static array like
>>>byte[2] data = [0, 1];
than its not GC allocated.

June 12, 2018
On 6/12/18 10:18 AM, SrMordred wrote:
> On Tuesday, 12 June 2018 at 12:29:17 UTC, rikki cattermole wrote:
>> (...)
> 
> this line:
>>>> byte[] data = [0, 1];
> is an dynamic array allocated with GC.
> But if you declare as a static array like
>>>> byte[2] data = [0, 1];
> than its not GC allocated.
> 

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
June 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.
>
> -Steve
Indeed, i´m creating my own "toolkit" for betterC stuff like
alloc!Type(length); (much safer than malloc!) and other utilities :)


June 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){
June 13, 2018
On Tuesday, 12 June 2018 at 18:41:57 UTC, Walter Bright wrote:
> 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){

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.

June 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!