Re: Can an M4-program read data out of an C-program?

"Raphael 'kena' Poss" <[email protected]>
Newsgroups gmane.comp.gnu.m4.general
Message-ID <[email protected]>
Op 22 mrt 2010, om 10:59 heeft Amaury Ampe het volgende geschreven:
> Is this done by using the sprintf command or can I just write it like that in my C-program?

use fprintf, like this:

  FILE *f = fopen("themacros.m4", "w");
  for (i = 0; i < N; ++i)
     fprintf(f, "m4_define([NAME%d], [%s])\n", i, your_data_for_item_i);
  fclose(f);

  system("m4 themacros.m4  thetemplatecode.m4 >output.c");


But my advice would be that you should really ask for help with this, or learn some basics on programming. Otherwise you will run quickly into issues and this mailing list is not intended to help with programming C.


-- 
Raphael 'kena' Poss · [email protected] · +31 20 525 7559
UvA · FNWI · IvI · CSA · 1098XG 107 Amsterdam (NL)
z = \f. (\x. f (\y. x x y)) (\x. f (\y. x x y))
There is no spoon, only fork() and vfork().
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.