爱意满满的作品展示区。
duyanning

cpps: c++脚本的(伪)解释器。像用 Python 一样用 c++

  •  
  •   duyanning · Aug 11, 2019 · 2404 views
    This topic created in 2488 days ago, the information mentioned may be changed or developed.
    https://github.com/duyanning/cpps/blob/master/README.chinese.md

    我做了个 c++脚本的(伪)解释器。
    可以这样执行 c++代码:
    cpps hello.cpp

    还能这样:
    chmod +x hello.cpp
    ./hello.cpp

    原理很简单,就是调用底层编译器(gcc/mingw/vc)进行编译,然后自动执行生成的可执行文件。
    但其实又比这个复杂点,因为支持多个.cpp ,还支持预编译头文件。
    目前支持 GCC/MinGW/Visual C++做底层编译器,也就是你机子上得装这三者之一才行。

    嗯,看上去是个解释器,其实是个 make 类工具。
    求 bug 报告
    2 replies    2019-08-12 14:23:38 +08:00
    ipwx
        1
    ipwx  
       Aug 11, 2019 via Android
    比起 cling 你有啥优势?
    duyanning
        2
    duyanning  
    OP
       Aug 12, 2019
    @ipwx 定位不一样,cling 还有更早的 cint,目的是在程序中嵌入 c++解释器。cpps 的优势是速度(因为会缓存编译结果)、build system(支持多文件、各种编译选项)。可以这样类比,cling 对标的是在其他程序中嵌入的 python 解释器以及 python 的 REPL 环境。而 cpps 对标的是独立的 python 脚本以及 make。cpps 距离程序员的日常工作更近,比如:cpps 可以自动调用 Qt 的 moc 对.h 进行处理,并将产生的.cpp 加入项目。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1016 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:12 · PVG 06:12 · LAX 15:12 · JFK 18:12
    ♥ Do have faith in what you're doing.