do not define __offsetof twice

pull/3182/head
Alexander Medvednikov 2019-12-22 01:01:44 +03:00
parent 5cfbc7bab5
commit 749d3ec14d
2 changed files with 6 additions and 3 deletions

View File

@ -21,8 +21,10 @@ const (
#endif
// for __offset_of
#ifndef __offsetof
#define __offsetof(s,memb) \\
((size_t)((char *)&((s *)0)->memb - (char *)0))
#endif
#define OPTION_CAST(x) (x)
'

View File

@ -1056,7 +1056,7 @@ pub fn new_v(args []string) &V {
is_live: '-live' in args
sanitize: '-sanitize' in args
// nofmt: '-nofmt' in args
show_c_cmd: '-show_c_cmd' in args
translated: 'translated' in args
is_run: 'run' in args
@ -1075,7 +1075,7 @@ pub fn new_v(args []string) &V {
building_v: !is_repl && (rdir_name == 'compiler' || rdir_name == 'v.v' || dir.contains('vlib'))
comptime_define: comptime_define
// is_fmt: comptime_define == 'vfmt'
user_mod_path: user_mod_path
vlib_path: vlib_path
vpath: vpath
@ -1133,7 +1133,6 @@ pub fn env_vflags_and_os_args() []string {
}
pub fn vfmt(args []string) {
println('running vfmt...')
file := args.last()
if !os.exists(file) {
println('"$file" does not exist')
@ -1147,11 +1146,13 @@ pub fn vfmt(args []string) {
// launch_tool('vfmt', '-d vfmt')
vroot := os.dir(vexe)
os.chdir(vroot)
println('building vfmt... (it will be cached soon)')
ret := os.system('$vexe -o $vroot/tools/vfmt -d vfmt v.v')
if ret != 0 {
println('err')
return
}
println('running vfmt...')
os.exec('$vroot/tools/vfmt $file')or{
panic(err)
}