Prev: How to run multiple commands in -exec of find command
Next: Finding the largest files in a filesystem (or highest values in a list) quickly
From: Geoff Clare on 26 Jan 2010 08:42 Stephane CHAZELAS wrote: > Now one may wonder why we didn't use > > gcc -dM -E /dev/null > > The thing is, with that syntax, gcc doesn't know which language > the file is written in as it has no extension. "-" has no > extension either but for some reason, gcc seems to assume "c". > > So you need: > > gcc -dM -E -x c /dev/null > > I would tend to prefer that latter syntax, as you make it clear > which language you want to know pre-defined macros for. You may also want to specify which version of the C language you are using, as it can affect the output: $ diff <(gcc -dM -E -x c -std=c89 /dev/null) \ <(gcc -dM -E -x c -std=c99 /dev/null) 79a80 > #define __STDC_VERSION__ 199901L 98a100 > #define __GNUC_STDC_INLINE__ 1 117d118 < #define __GNUC_GNU_INLINE__ 1 -- Geoff Clare <netnews(a)gclare.org.uk>
From: frank on 27 Jan 2010 01:33 Seebs wrote: > On 2010-01-25, frank <frank(a)example.invalid> wrote: >>> You will likely find, when you read the ?gcc(1)? man page, that the ?-? >>> argument is specifying that the program's main input is to be read from >>> the process's standard input, instead of a named file. > >> It certainly does. Can we talk about the hyphen in the middle that >> doesn't seem to do anything? > > Read that paragraph. > > -s I'm fine getting old school with things, and I'm grateful that you made me aware of this. It has entered my linuxlog: man gcc I crapped out at page 669. -- frank
From: frank on 27 Jan 2010 01:41 Stephane CHAZELAS wrote: > 2010-01-24, 22:26(-07), frank: >> Hello newsgroup, >> >> I'm relatively new to linux and have yet to put it through its paces >> properly, but I keep pecking away at it. I'm looking for a precise >> description of what's going on here: >> >> gcc -dM -E - < /dev/null >> >> Let me bust up the question a bit: >> gcc : invokes compiler >> -dM : show all the macros from preprocessing >> -E : stop after preprocessor >> - : no idea what a hyphen is doing here >> < : redirecting >> /dev/null/ : the bitbucket why would any macro be defined here? > [...] > > As already been said, "-" is a way to say "use stdin" and < > /dev/null makes stdin /dev/null. > > Now one may wonder why we didn't use > > gcc -dM -E /dev/null > > The thing is, with that syntax, gcc doesn't know which language > the file is written in as it has no extension. "-" has no > extension either but for some reason, gcc seems to assume "c". > > So you need: > > gcc -dM -E -x c /dev/null > > I would tend to prefer that latter syntax, as you make it clear > which language you want to know pre-defined macros for. Rather > than relying on the undocumented (well, at least I couldn't find > the documentation) fact that C is assumed for "-". > Thanks so much for your comments. I've entered them into my linuxlog. Cheers,
From: frank on 27 Jan 2010 01:46 Geoff Clare wrote: > Stephane CHAZELAS wrote: > >> Now one may wonder why we didn't use >> >> gcc -dM -E /dev/null >> >> The thing is, with that syntax, gcc doesn't know which language >> the file is written in as it has no extension. "-" has no >> extension either but for some reason, gcc seems to assume "c". >> >> So you need: >> >> gcc -dM -E -x c /dev/null >> >> I would tend to prefer that latter syntax, as you make it clear >> which language you want to know pre-defined macros for. > > You may also want to specify which version of the C language > you are using, as it can affect the output: > > $ diff <(gcc -dM -E -x c -std=c89 /dev/null) \ > <(gcc -dM -E -x c -std=c99 /dev/null) > 79a80 > > #define __STDC_VERSION__ 199901L > 98a100 > > #define __GNUC_STDC_INLINE__ 1 > 117d118 > < #define __GNUC_GNU_INLINE__ 1 Thanks, Geoff, unfortunately you need to dumb it down to me: @dan-desktop:~/source/unleashed/ch11$ diff <(gcc -dM -E -x c -std=c89 /dev/null) \ > <(gcc -dM -E -x c -std=c99 /dev/null) 80a81 > #define __STDC_VERSION__ 199901L 99a101 > #define __GNUC_STDC_INLINE__ 1 118d119 < #define __GNUC_GNU_INLINE__ 1 dan(a)dan-desktop:~/source/unleashed/ch11$ 79a80 bash: 79a80: command not found dan(a)dan-desktop:~/source/unleashed/ch11$ > #define __STDC_VERSION__ 199901L bash: syntax error near unexpected token `newline' dan(a)dan-desktop:~/source/unleashed/ch11$ 98a100 bash: 98a100: command not found dan(a)dan-desktop:~/source/unleashed/ch11$ > #define __GNUC_STDC_INLINE__ 1 bash: syntax error near unexpected token `newline' dan(a)dan-desktop:~/source/unleashed/ch11$ 117d118 bash: 117d118: command not found dan(a)dan-desktop:~/source/unleashed/ch11$ < #define __GNUC_GNU_INLINE__ 1 --
From: Seebs on 27 Jan 2010 03:00
On 2010-01-27, frank <frank(a)example.invalid> wrote: >> $ diff <(gcc -dM -E -x c -std=c89 /dev/null) \ >> <(gcc -dM -E -x c -std=c99 /dev/null) >> 79a80 >> > #define __STDC_VERSION__ 199901L >> 98a100 >> > #define __GNUC_STDC_INLINE__ 1 >> 117d118 >> < #define __GNUC_GNU_INLINE__ 1 > Thanks, Geoff, unfortunately you need to dumb it down to me: The thing after the $, and the next line (because of the \), were the command. The rest of this was output from that command on his system, which he included in the post for illustration. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! |