This is the mail archive of the cygwin-talk mailing list for the cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: how come #include "*.cpp" works?


On 17 May 2006 16:43, mwoehlke wrote:

> Larry Hall (Cygwin) wrote:
>> This isn't a Cygwin specific problem so it's off-topic for this list.
>> Please find a better forum for such questions.  If you feel you must
>> continue this discussion with a Cygwin crowd, then you can try the
>> cygwin-talk list.

  BTW, an interesting point arises from that thread:

  Everyone who replied chimed in with advice that the problem resulted from a
doubled include, and showed the OP how to use include guards to prevent the
resultant duplicate redefinitions.

  However,

1)  The OP was reporting *UN*defined symbol errors, not multiply-defined
errors;
2)  Nothing was being repeatedly included; each .cpp #included the header just
once, correctly;
3)  The division of declarations in the header file and definitions in the
.cpp file was completely correct; there are no definitions in the header so
nothing would get instantiated in both modules and cause a link error;
4)  The testcase compiles and runs fine!

  The only thing I can imagine is that OP got his compile command-lines messed
up, and was trying to fully compile-and-link each of the modules separately,
having missed out the -c option; so it compiled OK but then got link errors at
the end of the build.  When one .cpp was included in the other, the whole
thing was complete and all the links resolved.

  So, I think Larry should have written something more like

>> This isn't a Cygwin specific problem so it's off-topic for this list.
>> Please find a better forum for such questions, because nobody's
>> actually paying sufficient attention here.  If you feel you must
>> continue this discussion with a Cygwin crowd, then you can try the
>> cygwin-talk list, because irrelevant advice about dropping a hippo
>> on it is probably preferable to realistic-seeming yet completely
>> misleading advice.

  I guess if you've got a hammer, and every problem looks like a nail, then
everything that goes wrong is going to look like hitting your thumb....

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]