The code is quite simple :
test$ cat test.cpp
int main()
{
}
Is there a way to compile the code that is coming from a standard output?
I have tried this :
cat test.cpp | g++ -
and some variations, but none produced executable.
Just some clarifications. I have a program which preprocess a file, and produces another file which I want to compile. I thought about not creating this intermediate file, but to instead produce the object file directly.
cat
-ing a file... so the middle man is there. If your intention was typing directly into the compiler, then chances are that for anything not absolutely trivial you will make a typo and will have to retype (I know, I have usedcat
as an editor a few times which is fine if you never mistype)... – Situation/tmp/
), and fork agcc
or amake
process to compile it. Read my answer here – Blistery