Date: Thu, 5 Dec 1996 19:12:53 +0200 (IST) From: Eli Zaretskii To: "A.Appleyard" cc: DJGPP AT delorie DOT com Subject: Re: v2 funnies In-Reply-To: <1119426E71@fs2.mt.umist.ac.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 5 Dec 1996, A.Appleyard wrote: > (1) In v2, if I call open("filename",mode) with two args to create a new > file and write to it, even if I use mode O_RDWR, the file is created with its > DOS readonly attribute set so it can't be altered or deleted afterwards > (unless I state the permission required, as open("filename",mode,S_IWUSR)). > This is unexpected and annoying, and did not happen in v1. Why is this? I don't know, because the above doesn't happen to me. The small program attached below will cheerfully create a file, write the string to it, close it and leave it with both read *and* write access. This is DJGPP v2.01. Doesn't it work for you? > (2) How can I look through a big Gnu C++ program for unused functions and > global variables? I was once advised to use NM, which I just did; but I could > not see in its output anything that told me whether each symbol is ever > referred to or not. NM prints a letter between the address and the name of the symbol. That letter tells you what kind of reference to the symbol is at that address. A capital `T' (text) means this is a definition of a function; a `u' (undefined) means that the symbol is referenced but not defined (like if you call a function, or declare a variable `extern'); a capital `D' means definition of a variable (there are also other letters). So if you run "nm -A" on all of your .o object files, leave only the symbol names and those single letters, then sort the resulting list, you should be able to see which functions/variables are only defined but not referenced. For example, a function which is only defined but not called will only have its name with a `T', but not with a `u'. Note that I never tried these exact chores with NM, so the reality might be a bit more complex than what I describe, but at least the above procedure should produce a good approximation which you will be able to sort out yourself.