#!/bin/sh # gcc-macros --- display all predefined macros in gcc # Author: Noah Friedman # 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 ${ccprog-${CC-gcc}} ${1+"$@"} /dev/null | sort # eof