return list;
}
+static char *cflags_list(const struct manifest *m)
+{
+ unsigned int i;
+ char *ret = tal_strdup(m, cflags);
+
+ char **flags = get_cflags(m, m->dir, get_or_compile_info);
+ for (i = 0; flags[i]; i++)
+ tal_append_fmt(&ret, " %s", flags[i]);
+ return ret;
+}
+
/* FIXME: Test with reduced features! */
static bool compile(const void *ctx,
struct manifest *m,
char **output)
{
struct manifest **deps = get_example_deps(m, file);
+ const char *flags = cflags_list(m);
file->compiled[COMPILE_NORMAL] = temp_file(ctx, "", file->fullname);
if (!compile_and_link(ctx, file->fullname, ccan_dir,
example_obj_list(file, deps),
- compiler, cflags,
+ compiler, flags,
example_lib_list(file, deps),
file->compiled[COMPILE_NORMAL],
output)) {
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,
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",
/* This implies we start a function here. */
start_main(&ret, why);
has_main = true;
+ fake_main = true;
fake_function = true;
in_function = true;
}
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) {
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;
}
return NULL;
contents = mangle(m, lines);
- if (write(fd, contents, strlen(contents)) != strlen(contents)) {
+ if (write(fd, contents, strlen(contents)) != (int)strlen(contents)) {
close(fd);
return NULL;
}
}
static void build_examples(struct manifest *m,
- unsigned int *timeleft, struct score *score)
+ unsigned int *timeleft UNNEEDED, struct score *score)
{
struct ccan_file *i;
char **prev = NULL;