-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgcc-macros
executable file
·57 lines (46 loc) · 1.55 KB
/
gcc-macros
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# gcc-macros --- display all predefined macros in gcc
# Author: Noah Friedman <[email protected]>
# Public domain
# $Id: gcc-macros,v 1.1 2005/10/13 03:18:47 friedman Exp $
# Commentary:
# By default this will print all the predefined macros for a vanilla C file.
# To override the language, use -x{c++,assembler} etc.
# To change the language standards conformance,
# use -std={c89,c99,gnu89,gnu99,c++98,gnu++98} etc.
# Code:
case ${LANG+is_set} in
is_set ) LANG=C ;;
esac
xlang=c
# See if we should change the default lang used here because of a -std arg.
# A few other knobs and frobs here also.
for arg in ${1+"$@"} ; do
case $arg in
-std=*++* | -x[cg]++ | [cg]++ ) xlang=c++ ; shift ;;
-prog=* )
shift
arg=`echo "$arg" | sed -e 's/^[^=]*=//'`
ccprog=`${CC-gcc} -print-prog-name=$arg` ;;
-noargs | -noxargs ) shift; noxargs=t ;;
esac
done
# osx10.2/darwin6.8 note: `gcc -dM' will not display any macros because it
# calls cpp-precomp, which doesn't print the defines it knows about.
# However when invoking for c++ it does call cpp0.
case $xlang in
c ) case `uname -s`:`uname -r` in
Darwin:6.[0-8] ) CC=${CC-cpp} ;;
esac ;;
esac
# If -x[foo] is passed on the command line, it will override the -x arg here.
# Some versions of cpp (gcc 3.1?) will not do the right thing if -x and [foo]
# are separated by a space.
case $noxargs in
t ) set fnord -dM ${1+"$@"} ;;
* ) set fnord -dM -E -x$xlang ${1+"$@"} ;;
esac
shift
echo ${ccprog-${CC-gcc}} ${1+"$@"}
${ccprog-${CC-gcc}} ${1+"$@"} /dev/null | sort
# eof