From: Rusty Russell Date: Sun, 6 Nov 2016 04:35:17 +0000 (+1030) Subject: tools/ccanlint: add args to main. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=7307b7ef3cf1d226ade30ca5d7aa524bdd396715;hp=ad2ce76c10f808283ea7cf25cd8e76a15710c4f3;ds=sidebyside 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 --- diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c index cb71bf83..2ca2f34c 100644 --- a/tools/ccanlint/tests/examples_compile.c +++ b/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; }