0Day Forums
What does "- < /dev/null" mean in "gcc -dM -E - < /dev/null"? - Printable Version

+- 0Day Forums (https://0day.red)
+-- Forum: Coding (https://0day.red/Forum-Coding)
+--- Forum: C & C++ (https://0day.red/Forum-C-C)
+--- Thread: What does "- < /dev/null" mean in "gcc -dM -E - < /dev/null"? (/Thread-What-does-quot-lt-dev-null-quot-mean-in-quot-gcc-dM-E-lt-dev-null-quot)



What does "- < /dev/null" mean in "gcc -dM -E - < /dev/null"? - kwongmi - 07-27-2023

I know that using

<!-- language: lang-bash -->

gcc -dM -E - < /dev/null

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

<!-- language: lang-bash -->

- < /dev/null

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


[1]:

[To see links please register here]




RE: What does "- < /dev/null" mean in "gcc -dM -E - < /dev/null"? - transhipped89034 - 07-27-2023

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.