c2v icon indicating copy to clipboard operation
c2v copied to clipboard

C files to V translated successfully but all got plenty of errors when running.

Open rakshasha-medhi opened this issue 2 years ago • 0 comments

There were 3 files I translated, all exhibits similar characteristics: all translated successfully but lots of errors when running the file. Starting from sorting_algorithms (bubble sort, heap sort, etc) Then I pull out a simpler C file: calculate_pi Lastly I tried a hello_world C file --> translated successfully and some errors, but after manual fixing here and there I got it to run.

here is my hello_world.c

#include <stdio.h>

int main(void)
{
    const char lang[] = "C";
    const char object[] = "World";
    printf("Hello, %s %s!\n", lang, object);
    
    return 0;
}

below is the translated hello_world.v

@[translated]
module main

type Size_t = i64
type Ssize_t = i64
type Rsize_t = usize
type Intptr_t = i64
type Uintptr_t = i64
type Ptrdiff_t = i64
type Wchar_t = u16
type Wint_t = u16
type Wctype_t = u16
type Errno_t = int
type Time_t = Time64_t
type pthreadlocinfo = voidptr
type pthreadmbcinfo = voidptr
struct Locale_tstruct { 
	locinfo Pthreadlocinfo
	mbcinfo Pthreadmbcinfo
}
type _locale_t = voidptr
struct LC_ID { 
	wLanguage u16
	wCountry u16
	wCodePage u16
}
type LPLC_ID = voidptr
struct Threadlocinfo { 
	_locale_pctype &u16
	_locale_mb_cur_max int
	_locale_lc_codepage u32
}
struct FILE { 
	_Placeholder voidptr
}
type _off_t = int
type Off32_t = int
type _off64_t = i64
type Off64_t = i64
type Off_t = Off32_t
type Fpos_t = i64
fn main()  {
	lang := c'C'
	object := c'World'
	C.printf(c'Hello, %s %s!\n', lang, object)
	return 
}

below is the error messages I got when trying to run the hello_world.v WindowsTerminal_I6Mw3cRtxE

as you can see the errors are minor typos...but why these errors appeared in the first place? I mean in the Youtube demo, you translated the whole DOOM game...why translating just a hello_world script ended up with these errors?

For the other files I just don't bother anymore coz it's a lot and lots of minor errors that needed fixing. Also looking at there are some open issues relating to the same error...should we expect a fix sometime soon?

V 0.4.4 4145669 C2V latest version using GCC version 13.2.0 from winlibs

rakshasha-medhi avatar Feb 15 '24 11:02 rakshasha-medhi