From 7a132e5c794897e263e1d4a3018e349e3919e4a2 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 24 Apr 2020 08:42:26 +0300 Subject: [PATCH] cgen: cleaner comptime ifdefs . --- vlib/v/gen/cgen.v | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 14106e0f65..22a63d063f 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2760,11 +2760,9 @@ fn (g Gen) is_importing_os() bool { fn (mut g Gen) comp_if(it ast.CompIf) { ifdef := g.comp_if_to_ifdef(it.val, it.is_opt) if it.is_not { - g.writeln('\n#ifndef ' + ifdef) - g.writeln('// #if not $it.val') + g.writeln('\n// \$if !${it.val} {\n#ifndef ' + ifdef) } else { - g.writeln('\n#ifdef ' + ifdef) - g.writeln('// #if $it.val') + g.writeln('\n// \$if ${it.val} {\n#ifdef ' + ifdef) } // NOTE: g.defer_ifdef is needed for defers called witin an ifdef // in v1 this code would be completely excluded @@ -2786,7 +2784,7 @@ fn (mut g Gen) comp_if(it ast.CompIf) { g.stmts(it.else_stmts) g.defer_ifdef = '' } - g.writeln('\n#endif') + g.writeln('\n// } ${it.val}\n#endif\n') } fn (mut g Gen) go_stmt(node ast.GoStmt) {