Re: using #ifndef
From: Keith Thompson (kst-u_at_mib.org)
Date: Fri, 27 Aug 2004 21:29:58 GMT
"John Hanley" <firstname.lastname@example.org> writes:
> "Keith Thompson" <email@example.com> wrote in message
> > This is Usenet, not email. The difference is significant; though your
> > remarks here might be aimed at one person, there are many more
> > listening in.
> True. I actually was replying to an email. Mr. Tisdale had replied
> to my post over email and cc'd the newsgroup. I did a reply all and
> replied to both. I should've realized it probably shouldn't have
> gone to the newsgroup as well (being more of a personal reply). My
> apologies for breaking any Usenet etiquette.
In my opinion, that was ERT's fault for sending his response both by
e-mail and to the newsgroup. It rarely makes sense to do that. If I
see an e-mail response to something I've posted on Usenet, I'm likely
to assume that it was only a private response, and reply to it
privately; later, when I check the newsgroup, I find that I wasted my
time when I should have just posted publicly. (Actually, I'm more
likely to check first, since I've fallen into this trap a couple of
times.) If a response is sent both by e-mail and to the newsgroup, it
should be clearly labeled at the top.
> > You can continue describing what you're doing, and we can continue
> > telling you we don't know what the problem is. Or you can show us
> > what you're doing, and we can probably help. The choice is yours (but
> > one of the choices would be a collosal waste of time and, well, rude.)
> Ok, here's my header file r_climat.h
> struct data_record
I don't believe your header file has a "..." in the definition of
struct data_record. More on that below.
> As for my "multiple declaration" problem, here's the snippet of my .c files:
> int main(int argv, char * argc)
> main program here
> >and here's r_climat.c
> #include "r_climat.h"
> and the rest of my functions that would take another 800 lines or so.
I'm glad to see from another response you posted in this thread that
you were able to figure out the problem (something about another file
that your IDE picked up when you didn't want it to). But I'm going to
offer some constructive criticism anyway. Keep in mind this is
absolutely meant to be *constructive* criticism; it's also for the
benefit of other readers.
After going back and forth several times, you never actually gave us
what we asked for. First, you gave us a brief summary of what your
source code looked like. Then, you gave us snippets of your source
code (see above), but nothing that anyone else could actually compile.
What you should have done was something like this:
Copy all your source files to a separate directory (or the equivalent
for your system) and start ripping things out. If you're getting an
error message that refers to a particular function, delete everything
other than that one function. Delete everything you can from the body
of the function; narrow it down to something like:
some_type my_func(int foo, char *bar)
and narrow your main program down to:
result = my_func(0, NULL);
At each step, from the complete source code down to a minimal version
of it, recompile and confirm that you're still getting the same error
message. With luck, you'll be able to narrow the problem down to a
few dozen lines of code, small enough to post here. If you're really
lucky, you'll figure out while you're doing this what the problem is
(in your case, you probably would have figured that out the first time
you tried to compile in a new directory). The important point is that
the rest of us can then try compiling your code ourselves. If the
code you post has things like "..." and "main program here", we can't
When we ask for the exact code that's causing the problem, we mean
exactly that -- the *exact* code, not a summary, not a snippet. If
the code causing the problem is too big to post, you can almost
certainly trim it. If you're looking at problem that shows up during
compilation or linking, the trimmed version of the program doesn't
even have to do anything useful, as long as it produces the same error
And speaking of error messages, you should also post the exact error
message. Telling us that the compiler "tells me there are multiple
definitions of each of my functions" may not be sufficient;
cut-and-paste the actual error message. If you haven't figured out
the problem, don't assume that your summary of the error message won't
leave out some critical detail that you haven't recognized.
Finally, let me recommend a web page that probably covers everything
I've written here better than I have: "How To Ask Questions The Smart
Way" by Eric Raymond and Rick Moen,
-- Keith Thompson (The_Other_Keith) firstname.lastname@example.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this.