m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Amaury Ampe
Subject: Re: Can an M4-program read data out of an C-program?
Date: Mon, 22 Mar 2010 10:40:21 +0100
User-agent: Internet Messaging Program (IMP) H3 (4.1.6)

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 <address@hidden>:


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 · address@hidden · +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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]