Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "- < /dev/null" mean in "gcc -dM -E - < /dev/null"?

Tags:

c++

c

bash

gcc

I know that using

gcc -dM -E - < /dev/null

can get the predifined macros of gcc, but what does the

- < /dev/null

mean in this command? Per my understanding, there should be a option behind -. I have tried to search on gcc manual, but can't find answers.

like image 895
Nan Xiao Avatar asked Jun 30 '14 02:06

Nan Xiao


1 Answers

On its own, - means "read from standard input instead of the filename that would otherwise be provided on this command-line". This is a common Unix convention.

The < /dev/null redirects standard input from /dev/null, which is of length 0. Thus GCC will read from standard input and immediately reach the end of the input, causing it to print only the predefined macros (and not any macros in input, because there isn't any input). This is standard shell syntax, not specific to invocation of GCC.

Together, they are a way to provide no input to a process that expects some.

like image 98
Jeffrey Bosboom Avatar answered Sep 19 '22 10:09

Jeffrey Bosboom