Browse Source

tools/ccanlint: add args to main.

This allows examples to refer to them, but we cast them to void at the
end to avoid -Wunused warnings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell 9 years ago
parent
commit
7307b7ef3c
1 changed files with 7 additions and 2 deletions
  1. 7 2
      tools/ccanlint/tests/examples_compile.c

+ 7 - 2
tools/ccanlint/tests/examples_compile.c

@@ -442,7 +442,7 @@ static char *mangle(struct manifest *m, char **lines)
 	if (!has_main) {
 		ret = tal_strcat(m, take(ret),
 			     "/* Need a main to link successfully. */\n"
-			     "int main(void)\n{\n");
+			     "int main(int argc, char *argv[])\n{\n");
 		fake_function = true;
 	}
 
@@ -460,8 +460,13 @@ static char *mangle(struct manifest *m, char **lines)
 		tal_append_fmt(&ret, "	%s\n", use_funcs);
 	}
 
+	if (!has_main)
+		ret = tal_strcat(m, take(ret),
+				 "(void)argc; (void)argv;\n");
+	
 	if (fake_function)
-		ret = tal_strcat(m, take(ret), "return 0;\n}\n");
+		ret = tal_strcat(m, take(ret),
+				 "return 0;\n}\n");
 	return ret;
 }