mattiasgustavsson / dos-like

Engine for making things with a MS-DOS feel, but for modern platforms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about a specific line in `dos.h` being considered illegal

nahuakang opened this issue Β· comments

commented

πŸ‘‹ I followed Gustavo Pezzi's YouTube tutorial to implement a Voxel engine in C, which uses dos-like. It was fun and I wanted to port the implementation of that project into Zig while using dos-like.

But after setting everything up (current repository), I keep getting complaint on this specific dos.h line when running zig build run (which would properly link C libraries used in the src/zig.main):

Illegal instruction at address 0x231daa
dos/dos.h:333:17: 0x231daa in internals_build_font (/home/nahua/projects/zig/zigvoxel/dos/dos.c)
    if( b & ( 1 << u ) ) {
                ^
dos/dos.h:513:53: 0x32724d in internals_create (/home/nahua/projects/zig/zigvoxel/dos/dos.c)
    internals->graphics.fonts[ DEFAULT_FONT_8X8 ] = internals_build_font( font8x8 );
                                                    ^
dos/dos.h:2170:5: 0x31f867 in user_thread_proc (/home/nahua/projects/zig/zigvoxel/dos/dos.c)
    internals_create( context->sound_buffer_size );
    ^
???:?:?: 0x7f1ef15a9b42 in ??? (???)
The following command terminated unexpectedly:
cd /home/nahua/projects/_archive/zigvoxel && /home/nahua/projects/zig/zigvoxel/zig-out/bin/zigvoxel
error: the following build command failed with exit code 1:
/home/nahua/projects/zig/zigvoxel/zig-cache/o/9e426ccdbcedc4a377a31d1556fb8773/build /snap/zig/6463/zig /home/nahua/projects/zig/zigvoxel /home/nahua/projects/zig/zigvoxel/zig-cache /home/nahua/.cache/zig run

Not knowing enough C myself but knowing that Zig does sanitize some C usage which C compilers don't, may I ask if anyone can tell me why this specific bitwise left shift might be considered "illegal" by some stricter compiler? Thank you!