From: "A.Appleyard" Organization: Materials Science Centre To: DJGPP AT DELORIE DOT COM Date: Tue, 25 Feb 1997 16:33:18 GMT Subject: A program to find all unused symbols in a C program Message-ID: <34DB2D72539@fs2.mt.umist.ac.uk> Re the thread that I started re how to find unused global symbols in a big multi-file program, I just now quickly threw together this 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