generator.cxx 471 B

123456789101112131415161718192021222324
  1. #include <stdio.h>
  2. extern const char* foo();
  3. int main(int argc, const char* argv[])
  4. {
  5. if(argc < 3)
  6. {
  7. fprintf(stderr, "Must specify output file and symbol prefix!");
  8. return 1;
  9. }
  10. if(FILE* fout = fopen(argv[1], "w"))
  11. {
  12. fprintf(fout, "static const char* %s_string = \"%s\";\n", argv[2],
  13. foo());
  14. fclose(fout);
  15. }
  16. else
  17. {
  18. fprintf(stderr, "Could not open output file \"%s\"", argv[1]);
  19. return 1;
  20. }
  21. return 0;
  22. }