19

I followed the docs and compiled with nim compileToC helloworld.nim but it just spit out an executable. How can I see the intermediate C representation?

Elliot Gorokhovsky
  • 3,610
  • 2
  • 31
  • 56

3 Answers3

16

2019 Update (Nim 0.19.2)

The default nimcache directory has changed from the current working directory to:

  • $HOME/.cache/nim/<project_name> for Linux and MacOS
  • $HOME/nimcache/<project_name> for Windows

See the relevant nim compiler documentation article for details.

jkwill87
  • 658
  • 6
  • 8
15

nim -c -d:release c helloworld.nim just creates the C files in nimcache, without compiling and linking them. -d:release makes the code easier to read.

def-
  • 5,275
  • 20
  • 18
  • 4
    and `nimcache` location depends on OS, on my system the C files ended up under `~/.cache/nim/`, in a directory named after each nim source file, with suffix `_d` or `_r`, presumably for "debug" and "release". You can control this with `--nimcache:...` command line switch. – Hugues M. Sep 28 '18 at 11:33
3

Solved: When you compile a nim program a nimcache directory is automatically generated in the same directory that contains the c code.

Elliot Gorokhovsky
  • 3,610
  • 2
  • 31
  • 56