Article View: comp.os.msdos.programmer
Article #7941Re: What does this do?
From: Scott Fluhrer
Date: Sun, 10 Mar 1996 02:47
Date: Sun, 10 Mar 1996 02:47
49 lines
2085 bytes
2085 bytes
In <4hg4hv$iqb@hubcap.clemson.edu> ckirsch@eng.clemson.edu (Chuck
Kirschman) writes:
>
>I'm working in *somebody else's code*, which I'm sure everyone pretty
>much dreads. I've run across a construct which I don't understand the
>purpose of:
>
>void foo(int bar, float *baz)
>{
> int x,y;
>
> (void) x;
> (void) y;
>
> [rest of function]
>}
>
>What is the author trying to acheive?
Of the top, I can think of two plausible scenarios which could acount
for this:
Scenario 1:
- The programmer originally wrote function using the variables x
and y
- The programmer later rewrote the function, removing the
references to x and y, but not their declarations
- The programmer later went through getting rid of the compiler
warnings. Whenever if saw a 'unused variable' warning, he mindlessly
stuck in a dummy line to get rid of the warning, resulting in the
present code
If this is the case, you can safely ignore them, or delete them.
Scenario 2 (don't read this unless you have a strong stomache):
The programmer is playing games with the stack space. That is, he
figured out how stack space was allocated on his particular compiler,
and he happened to require 2 int's worth of space. Why he did this
travesty on portability and all common sense, rather that doing
something like explicitly allocating the space he required, I have no
idea. To see if he is doing this, look through the [rest of function]
code to see if he takes the address of an auto or a parameter, and does
arithmetic on the resulting pointer. If so, well, you just hit one of
the top coding nightmares :-(
>
>thanks
>chuck
poncho
Technical Details
Message-ID:
<4htfrr$ikn@reader2.ix.netcom.com>Path:
arc1-ca.pugleaf.net!ix.netcom.com!netnewsReferences:
<4hg4hv$iqb@hubcap.clemson.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ix.netcom.com!netnews From: sfluhrer@ix.netcom.com(Scott Fluhrer) Newsgroups: comp.os.msdos.programmer,comp.lang.c Subject: Re: What does this do? Date: 10 Mar 1996 02:47:23 GMT Organization: Netcom Message-ID: <4htfrr$ikn@reader2.ix.netcom.com> References: <4hg4hv$iqb@hubcap.clemson.edu> NNTP-Posting-Host: clv-oh8-20.ix.netcom.com X-NETCOM-Date: Sat Mar 09 6:47:23 PM PST 1996