Many thanks Hans. Thierry Le Friday 03 Sep 2021 à 14:16:40 (+0200), Hans Hagen a écrit :
in this case, thinking a bit different is easier ...
\starttext
\startbuffer[MyBuffer] #include <iostream>
using namespace std; int mysum(int,int); int a; int b; int main () { a=2; b=9; cout << mysum(a,b) << endl; return 0; } int mysum(int a, int b) { return a+b; } \stopbuffer
We compile and run:
\typebuffer[MyBuffer][option=C]
\startluacode io.savedata("test.cpp",buffers.getcontent("MyBuffer")) --os.execute("g++ -o test test.cpp") --os.execute("./test > test.tmp") os.execute("echo done > test.tmp") buffers.assign("MyBuffer",io.loaddata("test.tmp")) \stopluacode
And get:
\typebuffer[MyBuffer]
Or just:
\typefile{test.tmp}
\stoptext
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------