Did you know that you can run the compiler from sources specified in stdin? Â Here’s an example:
You have to specify the language for the code explicitly, since that can’t be inferred from the filename when that file data is coming from stdin:
This fact came up in conversation the other day. The result is something that is completely undebuggable, but you can do it! I’m curious if there’s actually a use case for this?
The one thing I can think of
“`generate_some_c_code | ssh remote_host_running_different_arch “clang -g -x c – -o f; ./f” | parse_output“`
That is, cross-compiling and running a quick test. This is a combination of two different things I’ve had to do at work lately. Neither one by itself posed a problem that this particular clang ability would have solved, but I could see something like this.
(Of course, `generate_some_c_code` could be `cat m.c`)
Nice. That’s a decent use case.