D code running on the Nintendo 3DS

Iain Buclaw ibuclaw at gdcproject.org
Mon Oct 21 19:03:00 UTC 2019


On Sun, 20 Oct 2019 at 20:40, TheGag96 via Digitalmars-d-announce
<digitalmars-d-announce at puremagic.com> wrote:
>
> On Sunday, 20 October 2019 at 15:27:35 UTC, Iain Buclaw wrote:
> > Great stuff!  Though I don't think you'll find much improvement
> > in gdc 10 regarding switching off D features.  Backported
> > patches to make gdc on parity with dmd as of April 2019 was
> > done prior to the gdc 9 release.  I'm not aware of much more
> > being done regarding that other than some extern(C) library
> > functions being converted into templates, and the C main
> > function being moved to a common location in D runtime (C main
> > is not "compiled into" gdc unlike previous versions of dmd).
>
> Darn... Are there any plans at some point in the future to add a
> real -betterC sort of flag? It would be really really nice to be
> able to compile something like...
>
> import std.bitmanip : bitfields;
>
> struct Stuff {
>    mixin(bitfields!(
>          uint, "x",    2,
>          int,  "y",    3,
>          uint, "z",    2,
>          bool, "flag", 1));
> }
>
> extern(C) void main() {
>    Stuff x;
> }
>
> ...just as in DMD or LDC.

You can compile that with gdc-9 just fine.

$ cat test.d
import std.bitmanip : bitfields;

struct Stuff {
   mixin(bitfields!(
         uint, "x",    2,
         int,  "y",    3,
         uint, "z",    2,
         bool, "flag", 1));
}

extern(C) void main() {
   Stuff x;
   x.x = 1;
   x.y = 42;
   x.z = 4;
   x.flag = true;
   return;
}

$ gdc -v 2>&1 | grep version
gcc version 9.2.0 (GCC)

$ gdc -fno-druntime test.d

$ nm a.out
0000000000004028 B __bss_start
0000000000004028 b completed.7380
                 w __cxa_finalize@@GLIBC_2.2.5
0000000000001142 T _D4test5Stuff1xMFNaNbNdNiNfkZv
0000000000001125 T _D4test5Stuff1xMxFNaNbNdNiNfZk
0000000000001194 T _D4test5Stuff1yMFNaNbNdNiNfiZv
000000000000116a T _D4test5Stuff1yMxFNaNbNdNiNfZi
00000000000011df T _D4test5Stuff1zMFNaNbNdNiNfkZv
00000000000011bf T _D4test5Stuff1zMxFNaNbNdNiNfZk
000000000000121e T _D4test5Stuff4flagMFNaNbNdNiNfbZv
000000000000120a T _D4test5Stuff4flagMxFNaNbNdNiNfZb
0000000000002004 R _D4test5Stuff6__initZ
0000000000004018 D __data_start
0000000000004018 W data_start
0000000000001070 t deregister_tm_clones
00000000000010e0 t __do_global_dtors_aux
0000000000003e00 t __do_global_dtors_aux_fini_array_entry
0000000000004020 D __dso_handle
0000000000003e08 d _DYNAMIC
0000000000004028 D _edata
0000000000004030 B _end
0000000000001314 T _fini
0000000000001120 t frame_dummy
0000000000003df8 t __frame_dummy_init_array_entry
000000000000228c r __FRAME_END__
0000000000004000 d _GLOBAL_OFFSET_TABLE_
                 w __gmon_start__
0000000000002008 r __GNU_EH_FRAME_HDR
0000000000001000 t _init
0000000000003e00 t __init_array_end
0000000000003df8 t __init_array_start
0000000000002000 R _IO_stdin_used
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
0000000000001310 T __libc_csu_fini
00000000000012b0 T __libc_csu_init
                 U __libc_start_main@@GLIBC_2.2.5
0000000000001259 T main
00000000000010a0 t register_tm_clones
0000000000001040 T _start
0000000000004028 D __TMC_END__

-- 
Iain


More information about the Digitalmars-d-announce mailing list