diff --git a/vlib/compiler/cflags.v b/vlib/compiler/cflags.v index 5e658b1042..d20fe4abe4 100644 --- a/vlib/compiler/cflags.v +++ b/vlib/compiler/cflags.v @@ -70,15 +70,16 @@ fn (table &Table) has_cflag(cflag CFlag) bool { // parse the flags to (table.cflags) []CFlag // Note: clean up big time (joe-c) -fn (table mut Table) parse_cflag(cflag string, mod string) { +fn (table mut Table) parse_cflag(cflag string, mod string) ?bool { allowed_flags := [ 'framework', 'library', 'I', 'l', 'L', ] - mut flag := cflag.trim_space() + flag_orig := cflag.trim_space() + mut flag := flag_orig if flag == '' { - return + return true } mut fos := '' mut name := '' @@ -124,6 +125,13 @@ fn (table mut Table) parse_cflag(cflag string, mod string) { value = flag.trim_space() index = -1 } + if (name in ['-I', '-l', '-L']) && value == '' { + if name == '-I' || name == '-L' { + return error('bad #flag `$flag_orig`: missing path after `-I`') + } else if name == '-l' { + return error('bad #flag `$flag_orig`: missing library name after `-l`') + } + } cf := CFlag{ mod: mod, os: fos, @@ -137,7 +145,7 @@ fn (table mut Table) parse_cflag(cflag string, mod string) { break } } - return + return true } //TODO: implement msvc specific c_options_before_target and c_options_after_target ...