checker: do not require fn main when building an object file

Alexander Medvednikov 2022-06-06 12:29:46 +03:00 committed by Chewing_Bever
parent d28840036c
commit 972190dcc0
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 4 additions and 3 deletions

View File

@ -368,7 +368,7 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
if !has_main_mod_file {
c.error('project must include a `main` module or be a shared library (compile with `v -shared`)',
token.Pos{})
} else if !has_main_fn {
} else if !has_main_fn && !c.pref.is_o {
c.error('function `main` must be declared in the main module', token.Pos{})
}
}

View File

@ -5486,8 +5486,9 @@ fn (mut g Gen) enum_val(node ast.EnumVal) {
// && g.inside_switch
if g.pref.translated && node.typ.is_number() {
// Mostly in translated code, when C enums are used as ints in switches
sym := g.table.sym(node.typ)
g.write('/* $node enum val is_number $node.mod styp=$styp sym=$sym*/_const_main__$node.val')
// sym := g.table.sym(node.typ)
// g.write('/* $node enum val is_number $node.mod styp=$styp sym=$sym*/_const_main__$node.val')
g.write('_const_main__$node.val')
} else {
g.write('${styp}__$node.val')
}