www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/05/12:25:16

Date: Thu, 5 Dec 1996 19:12:53 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
cc: DJGPP AT delorie DOT com
Subject: Re: v2 funnies
In-Reply-To: <1119426E71@fs2.mt.umist.ac.uk>
Message-ID: <Pine.SUN.3.91.961205185638.9964B-100000@is>
MIME-Version: 1.0

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019