X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fexamples_compile.c;h=5086239396840d524c9c4df2a3c613bb96bd14ca;hp=cb71bf8329db7e54227b7c26af94e97cfb2b18e6;hb=HEAD;hpb=9961094e2422cf0c2d9cb21387da7c65ddddafe2 diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c index cb71bf83..50862393 100644 --- a/tools/ccanlint/tests/examples_compile.c +++ b/tools/ccanlint/tests/examples_compile.c @@ -359,7 +359,8 @@ static char *strip_comment(const void *ctx, const char *orig_line) static char *mangle(struct manifest *m, char **lines) { char *ret, *use_funcs = NULL, *why; - bool in_function = false, fake_function = false, has_main = false; + bool in_function = false, fake_function = false, has_main = false, + fake_main = false; unsigned int i; ret = tal_fmt(m, @@ -393,6 +394,7 @@ static char *mangle(struct manifest *m, char **lines) fake_function = true; in_function = true; has_main = true; + fake_main = true; } else tal_append_fmt(&ret, "/* The example %s, so didn't wrap in main() */\n", @@ -429,6 +431,7 @@ static char *mangle(struct manifest *m, char **lines) /* This implies we start a function here. */ start_main(&ret, why); has_main = true; + fake_main = true; fake_function = true; in_function = true; } @@ -442,8 +445,9 @@ 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; + fake_main = true; } if (use_funcs) { @@ -460,8 +464,13 @@ static char *mangle(struct manifest *m, char **lines) tal_append_fmt(&ret, " %s\n", use_funcs); } + if (fake_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; }