v icon indicating copy to clipboard operation
v copied to clipboard

error: incompatible types for redefinition of 'memcpy' when use -freestanding

Open akbarfa49 opened this issue 3 years ago • 1 comments

V version: V 0.2.4 dcdfdf4.b482c05 OS: linux, "ArcoLinux"

What did you do? run v with command v run filename.v -freestanding

module main
import net

fn main() {
	mut addr := net.AddrFamily.ip
	mut ln := net.listen_tcp(addr, ":8081") or {
		panic(err)
	}
	for {
	mut conn := ln.accept() or {
			panic(err)
		}
		go handle_connection(mut conn)
	}
}

fn handle_connection(mut c &net.TcpConn){
	 hello := "hello world"
	res := "HTTP/1.1 200 OK\r\nContent-Length: " + hello.len.str() + "\r\nConnection: close\r\n\r\n" + hello
	c.write(res.bytes()) or {
	}
	c.close() or {
	
	}
}

What did you expect to see? no error

What did you see instead?


In file included from /tmp/v_1000/vblog.861675596276695499.tmp.c:903:
In file included from /usr/include/sys/un.h:37:
/usr/include/string.h:44: error: incompatible types for redefinition of 'memcpy'
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

akbarfa49 avatar May 19 '22 03:05 akbarfa49

I get the same error when trying to use SDL2:

jeff@jeffs-machine $ v -freestanding -cg .
In file included from /tmp/v_1000/project.11051791327570436486.tmp.c:730:
In file included from /usr/include/SDL2/SDL.h:32:
In file included from /usr/include/SDL2/SDL_main.h:25:
In file included from /usr/include/SDL2/SDL_stdinc.h:43:
In file included from /usr/include/stdio.h:36:
thirdparty/tcc/lib/tcc/include/stdarg.h:5: warning: va_start redefined
In file included from /tmp/v_1000/project.11051791327570436486.tmp.c:730:
In file included from /usr/include/SDL2/SDL.h:32:
In file included from /usr/include/SDL2/SDL_main.h:25:
In file included from /usr/include/SDL2/SDL_stdinc.h:43:
In file included from /usr/include/stdio.h:36:
thirdparty/tcc/lib/tcc/include/stdarg.h:6: warning: va_arg redefined
In file included from /tmp/v_1000/project.11051791327570436486.tmp.c:730:
In file included from /usr/include/SDL2/SDL.h:32:
In file included from /usr/include/SDL2/SDL_main.h:25:
In file included from /usr/include/SDL2/SDL_stdinc.h:43:
In file included from /usr/include/stdio.h:36:
thirdparty/tcc/lib/tcc/include/stdarg.h:7: warning: va_copy redefined
In file included from /tmp/v_1000/project.11051791327570436486.tmp.c:730:
In file included from /usr/include/SDL2/SDL.h:32:
In file included from /usr/include/SDL2/SDL_main.h:25:
In file included from /usr/include/SDL2/SDL_stdinc.h:43:
In file included from /usr/include/stdio.h:36:
thirdparty/tcc/lib/tcc/include/stdarg.h:8: warning: va_end redefined
In file included from /tmp/v_1000/project.11051791327570436486.tmp.c:730:
In file included from /usr/include/SDL2/SDL.h:32:
In file included from /usr/include/SDL2/SDL_main.h:25:
In file included from /usr/include/SDL2/SDL_stdinc.h:66:
/usr/include/string.h:44: error: incompatible types for redefinition of 'memcpy'
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang


jeffbdavenport avatar Feb 26 '23 16:02 jeffbdavenport