Compile string of C code

前端 未结 2 485
面向向阳花
面向向阳花 2021-02-08 23:51

Really off the wall question here, but is there a way to compile a string of C code in GCC without any medium to hold that string (eg. a source file)?

Something along th

2条回答
  •  日久生厌
    2021-02-09 00:31

    I confess to sometimes highlighting code and using:

    (cat preamble.hpp; xsel) | g++ -x c++ - && ./a.out
    

    The same works with "-x c" for C.

提交回复
热议问题