How can I find out cc or cpp symbols?

Randal L. Schwartz @ Stonehenge merlyn at intelob.intel.com
Mon Apr 24 05:46:11 AEST 1989


In article <19236 at adm.BRL.MIL>, rbj at dsys (Root Boy Jim) writes:
| You can do this by a somewhat roundabout route. First you run the command
| `strings' (if you have it) on the cpp binary. You then grep out only the
| legal preprocessor strings (only alphanumeric or underscores not starting
| with a digit). Then pipe it to an awk command which turns `foo' into
| 
| 		#ifdef foo
| 			printf("foo\n");
| 		#endif
| 
| and brackets the whole thing with "main () {" and "}". Sen the output
| to a file, compile it, link it, and run it. Voila!

Here's what I have... I call it 'whatdef':
	strings -2 /lib/cpp |
	grep '^[_A-Za-z][_A-Za-z0-9]*$' |
	sort -u |
	awk '
		{
			print "#ifdef " $0
			print "__" $0 "__ is defined"
			print "#endif"
		}
	' |
	/lib/cpp |
	sed -n 's/^__\(.*\)__ is defined$/\1/p'

I probably could have done the middle in sed, but I didn't feel like
hacking the backslashes and newlines.

Note the new address in the .sig....
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095===\
{ on contract to BiiN, Hillsboro, Oregon, USA, until 01 June 1989    }
{ <merlyn at intelob.intel.com> ...!uunet!tektronix!biin!merlyn         }
{ or try <merlyn at agora.hf.intel.com> after 01 June 1989              }
\=Cute quote: "Welcome to Oregon... home of the California Raisins!"=/



More information about the Comp.unix.questions mailing list