Message-ID: <3A363087.34F93458@umist.ac.uk> Date: Tue, 12 Dec 2000 14:04:55 +0000 From: Anthony Appleyard Organization: UMIST, Manchester, UK X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: finding unused variables in a multi-file program Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: aa1.mt.umist.ac.uk X-Trace: 12 Dec 2000 14:10:48 GMT, aa1.mt.umist.ac.uk Lines: 68 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In Feb 1997 I wrote this Gnu C program. Its call args should be the names of one or more *.S files created by djgpp -S . It will report in file `_.O' (in mangled form) all symbols declared but not used in those *.S files (which should be the *.S forms of all the files that make up one multi-file program). If you want to develop it further, you can. CXXFILT < _.O > _.OO will then produce in _.OO the same output with the symbol names demangled. ------------------------------------------------------------------- #include #include #include /*-----*/ /* the args should be names of *.S files created by djgpp -S */ int main(int nargs,char**arg){ FILE*F; int i,j,k,l,m,n=0,z=0; char*sw,L[1024],**sym,*x; puts("READING DEFINED SYMBOLS"); sym=(char**)(malloc(0x10000)); for(m=1;m>8; /* .ln number */ }} fclose(F);} for(k=i=n-1;k;i--) for(k=j=0;j0) {sw=sym[j+1]; sym[j+1]=sym[j]; sym[j]=sw; k=1;} for(i=n-1;i>0;i--) if(!strcmp(sym[i-1],sym[i])) sym[i][0]=0; /* mark the duplicates */ x=(char*)malloc(n); for(i=0;i'9') if(k<'0'?:k>'9') if(k<'A'?:k>'Z') if(k<'a'?:k>'z') L[i]=0; /* replace all non-symbol chars by ascii 0 */ for(i=0;i