6

I want to achieve the same effect as

gcc -dM -E - < /dev/null

(as described here) - but for nvcc. That is, I want to dump all of nvcc's preprocessor defines. Alas, nvcc doesn not support -dM. What do I do instead?

Community
  • 1
  • 1
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    You can get a sense of what "extra" preprocessor defines that `nvcc` is specifying when it is using `gcc` under the hood, by specifying the `-v` option while compiling. Perhaps something like this: `nvcc -v myfile.cu -o myfile 2>&1 >/dev/null |grep -e "-D"` – Robert Crovella Dec 29 '14 at 18:30
  • Don't you have to add `-x c`? – S.S. Anne Mar 20 '20 at 16:24
  • 1
    @S.S.Anne: Not for preprocessing you don't. Try it. – einpoklum Mar 20 '20 at 16:28

1 Answers1

7

Instead of -dM, pass --compiler-options -dM to nvcc. You should also add -x cu since the compiler doesn't know the file type of stdin. So your command line would be

nvcc --compiler-options -dM -E -x cu - < /dev/null
dragonroot
  • 5,653
  • 3
  • 38
  • 63