Re: Can an M4-program read data out of an C-program?
Amaury Ampe <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks a lot for your respons! It helps me a great deal on the way to a solution. The problem is that I have to transfer about a 120 values. Is it possible to do this with arrays or so? Or do I have to give each one an individual name and transfer them individualy? Quoting Raphael 'kena' Poss <[email protected]>: > > Op 19 mrt 2010, om 15:24 heeft Amaury Ampe het volgende geschreven: > >> I'm quite new to programming in general and completely new to M4, >> so any help would be most welcome. > > In your controller program in C: > > int thevalue = 1234; > > const char cmd[100]; > sprintf(cmd, "m4 -DPPCVAL=%d yourfile.m4 >thecode.c", thevalue); > > In your template file in M4: > > .... (some code already there...) ... > > asm("your assembly stuff using PPCVAL ...."); > > .... > > > to make a long story short: use -D with m4 to define a macro on the > command line. Use this macro by name in your generated C code. M4 > will replace the macro by its value even when it occurs within a C > string. > > > -- > 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(). > > > > > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.