# # # patch "txt2c.cc" # from [4bfb199702931f2c6e4729b4b4d6e90af48b66ee] # to [eedf5a5a6ba149eba89310b53ee08223983de6e9] # ============================================================ --- txt2c.cc 4bfb199702931f2c6e4729b4b4d6e90af48b66ee +++ txt2c.cc eedf5a5a6ba149eba89310b53ee08223983de6e9 @@ -20,7 +20,7 @@ int main(int argc, char **argv) } bool do_strip_trailing = false; - char const * static_decl = "static "; + bool do_static = true; int i = 1; if (string(argv[i]) == "--strip-trailing") { @@ -29,7 +29,7 @@ int main(int argc, char **argv) } if (string(argv[i]) == "--no-static") { - static_decl = "extern "; + do_static = false; i++; } char const * fname = argv[i++]; @@ -58,10 +58,19 @@ int main(int argc, char **argv) cout << "// DO NOT EDIT\n" << "// this file is automatically generated from " << fname << ",\n" << "// any changes you make will be destroyed when it is regenerated\n" - << "\n\n" - << static_decl - << "char const " << arr << "_constant[" << (dat.size() + 1) << "] = {\n"; + << "\n\n"; + if (do_static) + cout << "static "; + else + // some versions of g++ object to constants marked 'extern' and defined + // at the same time (i.e. constants declared with both 'extern' and an + // initializer). to shut them up, first declare the constant 'extern', + // then define it without 'extern'. + cout << "extern char const " << arr << "_constant[];\n"; + + cout << "char const " << arr << "_constant[" << (dat.size() + 1) << "] = {\n"; + for (unsigned int i = 0; i < dat.size(); ++i) { if (i == 0) cout << '\t';