如何获取nim程序的c代码?

Ell*_*sky 8 gcc nim-lang

我跟着文档编译,nim compileToC helloworld.nim 但它只是吐出一个可执行文件.我怎样才能看到中间C表示?

def*_*ef- 11

nim -c -d:release c helloworld.nim只需创建C文件nimcache,而无需编译和链接它们.-d:release使代码更容易阅读.

  • 和 `nimcache` 位置取决于操作系统,在我的系统上,C 文件最终位于 `~/.cache/nim/` 下,在以每个 nim 源文件命名的目录中,后缀为 `_d` 或 `_r`,大概是为了“调试”和“发布”。您可以使用`--nimcache:...` 命令行开关来控制它。 (2认同)

jkw*_*l87 11

2019 更新(Nim 0.19.2)

默认 nimcache 目录已从当前工作目录更改为:

  • $HOME/.cache/nim/<project_name> 适用于 Linux 和 MacOS
  • $HOME/nimcache/<project_name> 适用于 Windows

有关详细信息,请参阅相关的nim 编译器文档文章。