c2v icon indicating copy to clipboard operation
c2v copied to clipboard

Translation with is_prime example not working correctly on windows 10 64

Open extremety1989 opened this issue 2 years ago • 1 comments

this what i get

[translated]
module main

type Uintptr_t = i64
type Va_list = &i8
type Size_t = i64
type Ptrdiff_t = i64
type Intptr_t = i64
type Wchar_t = U16
type Errno_t = int
type Wint_t = U16
type Wctype_t = U16
struct Crt_locale_data_public { 
	_locale_pctype &u16
	_locale_mb_cur_max int
	_locale_lc_codepage u32
}
struct Crt_locale_pointers { 
	locinfo &crt_locale_data
	mbcinfo &crt_multibyte_data
}
type _locale_t = &crt_locale_pointers
struct Mbstatet { 
	_Wchar u32
	_Byte u16
	_State u16
}
type Mbstate_t = Mbstatet
type Time_t = Time64_t
type Rsize_t = Usize
struct FILE { 
	_Placeholder voidptr
}
type Fpos_t = i64
fn is_prime(x int) bool {
	for i := 2 ; i <= x / 2 ; i ++ {
		if x % i == 0 {
		return false
		}
	}
	return true
}

fn main()  {
	for i := 2 ; i < 100 ; i ++ {
		if is_prime(i) {
			C.printf(c'%i\n', i)
		}
	}
	return 
}

and error

v main.v
main.v:9:16: error: unknown type `U16`.
Did you mean `FILE`?
    7 | type Ptrdiff_t = i64
    8 | type Intptr_t = i64
    9 | type Wchar_t = U16
      |                ~~~
   10 | type Errno_t = int
   11 | type Wint_t = U16
main.v:11:15: error: unknown type `U16`.
Did you mean `FILE`?
    9 | type Wchar_t = U16
   10 | type Errno_t = int
   11 | type Wint_t = U16
      |               ~~~
   12 | type Wctype_t = U16
   13 | struct Crt_locale_data_public {
main.v:12:17: error: unknown type `U16`.
Did you mean `FILE`?
   10 | type Errno_t = int
   11 | type Wint_t = U16
   12 | type Wctype_t = U16
      |                 ~~~
   13 | struct Crt_locale_data_public {
   14 |     _locale_pctype &u16
main.v:19:11: error: unknown type `crt_locale_data`.
Did you mean `Crt_locale_data_public`?
   17 | }
   18 | struct Crt_locale_pointers {
   19 |     locinfo &crt_locale_data
      |              ~~~~~~~~~~~~~~~
   20 |     mbcinfo &crt_multibyte_data
   21 | }
main.v:20:11: error: unknown type `crt_multibyte_data`
   18 | struct Crt_locale_pointers {
   19 |     locinfo &crt_locale_data
   20 |     mbcinfo &crt_multibyte_data
      |              ~~~~~~~~~~~~~~~~~~
   21 | }
   22 | type _locale_t = &crt_locale_pointers
main.v:22:18: error: unknown type `crt_locale_pointers`.
Did you mean `Crt_locale_pointers`?
   20 |     mbcinfo &crt_multibyte_data
   21 | }
   22 | type _locale_t = &crt_locale_pointers
      |                  ~~~~~~~~~~~~~~~~~~~~
   23 | struct Mbstatet {
   24 |     _Wchar u32
main.v:29:15: error: unknown type `Time64_t`.
Did you mean `Time_t`?
   27 | }
   28 | type Mbstate_t = Mbstatet
   29 | type Time_t = Time64_t
      |               ~~~~~~~~
   30 | type Rsize_t = Usize
   31 | struct FILE {
main.v:30:16: error: unknown type `Usize`.
Did you mean `Rsize_t`?
   28 | type Mbstate_t = Mbstatet
   29 | type Time_t = Time64_t
   30 | type Rsize_t = Usize
      |                ~~~~~
   31 | struct FILE {
   32 |     _Placeholder voidptr

extremety1989 avatar Jul 20 '22 07:07 extremety1989

Thanks for the report!

Will fix.

medvednikov avatar Jul 20 '22 09:07 medvednikov