0

How can i compile the contents of the clipboard, i tried piping the contents pbpaste | gcc but it did not work it gave the error i686-apple-darwin11-llvm-gcc-4.2: no input files I have heard that i can use temporary file with the command mktemp but I could not get it to work.

kyle k
  • 5,134
  • 10
  • 31
  • 45

1 Answers1

2

Using -xc - will allow you to process stdin:

gcc -xc -

You can see a live example here.

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
  • I got this warning **i686-apple-darwin11-llvm-gcc-4.2: warning: '-x c-' after last input file has no effect** **i686-apple-darwin11-llvm-gcc-4.2: no input files** – kyle k Aug 25 '13 at 02:46
  • 1
    @kylek There needs to be a space between the `c` and `-` – Shafik Yaghmour Aug 25 '13 at 02:47
  • It won't compile anything it just freezes, my clipboard only contains a hello world program. – kyle k Aug 25 '13 at 02:56
  • 1
    @kylek this works fine in the live example I linked and in my linux VM, so there may be something weird about the format of the data coming from the clipboard, is it in plain text? Maybe you can [redirect to a file](http://stackoverflow.com/questions/6674327/redirect-all-output-to-file) and see if that will compile and if not determine what about the format is causing the problem. – Shafik Yaghmour Aug 25 '13 at 03:03