From 7ca3f68ac2aa6ee7cee632f8cd72cc3ef6c4faa9 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Mon, 25 Sep 2023 02:38:54 +0200 Subject: fix impl include order bug --- gen_inl.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'gen_inl.c') diff --git a/gen_inl.c b/gen_inl.c index 975b7a5..e5ec31e 100644 --- a/gen_inl.c +++ b/gen_inl.c @@ -101,12 +101,15 @@ int write_file(FILE *out, char *source) { return 1; } - fprintf(out, "/*%s*\n", repeat(67, '*')); - fprintf(out, " *%s*\n", repeat(67, ' ')); - fprintf(out, " * File: %s%s*\n", source, - repeat(55 - strlen(source), ' ')); - fprintf(out, " *%s*\n", repeat(67, ' ')); - fprintf(out, " *%s*/\n", repeat(67, '*')); + fprintf(out, "// " + "=====================================================" + "===========\n"); + fprintf(out, "//\n"); + fprintf(out, "// File: %s\n", source); + fprintf(out, "//\n"); + fprintf(out, "// " + "=====================================================" + "===========\n"); char line[200]; char buf[400]; @@ -147,7 +150,8 @@ int main(int argc, char **argv) { fprintf(out, "// kit.inl.h\n"); fprintf(out, "// https://guattari.tech/kit.git\n"); fprintf(out, "//\n"); - fprintf(out, "// Single header-only cross-platform utility library for C.\n"); + fprintf(out, "// Single header-only cross-platform utility " + "library for C.\n"); fprintf(out, "//\n"); fprintf(out, "// " "=====================================================" @@ -207,7 +211,19 @@ int main(int argc, char **argv) { return 1; } - fprintf(out, "#ifdef KIT_IMPLEMENTATION\n"); + fprintf(out, "#endif\n"); + fprintf(out, "// " + "=====================================================" + "===========\n"); + fprintf(out, "//\n"); + fprintf(out, "// IMPLEMENTATION\n"); + fprintf(out, "//\n"); + fprintf(out, "// " + "=====================================================" + "===========\n"); + fprintf(out, "#if defined(KIT_IMPLEMENTATION) && " + "!defined(KIT_INL_H_IMPL)\n"); + fprintf(out, "#define KIT_INL_H_IMPL\n"); for (int i = 0; i < sizeof IMPL / sizeof *IMPL; i++) if (write_file(out, IMPL[i]) != 0) { @@ -216,7 +232,6 @@ int main(int argc, char **argv) { } fprintf(out, "#endif\n"); - fprintf(out, "#endif\n"); fclose(out); return 0; -- cgit v1.2.3