Is it possible to compile a stream of data rather than compiling a .c
file using gcc? for example, is it possible that instead of having my code stored in any xyz.c
file, I can directly compile the code?
Conceptually, the C program deals with a stream instead of directly with a file. A stream is an idealized flow of data to which the actual input or output is mapped. That means various kinds of input with differing properties are represented by streams with more uniform properties.
Having created a stream, we can connect it to a file using the member function "open(...)".
A file stream is a sequence of bytes used to hold file data. Usually a file has only one file stream, namely the file's default data stream. However, on file systems that support multiple data streams, each file can have multiple file streams. One of these is the default data stream, which is unnamed.
Use gcc options -x
and -
$ echo -e '#include <stdio.h>\nmain(){puts("Hello world");return 0;}' | gcc -xc -ogarbage - && ./garbage && rm garbage Hello world
The single line command above is made up of the following parts:
echo -e '#include <stdio.h>\nmain(){puts("Hello world");return 0;}' # "source" | # pipe gcc -xc -ogarbage - # compile && # and ./garbage # run && # and rm garbage # delete
This may answer you question, though it is rarely useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With