Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* cxx annoyance
@ 2001-06-18 19:40 Tobias Ernst
  2001-06-19  2:30 ` Mark Garrett
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Tobias Ernst @ 2001-06-18 19:40 UTC (permalink / raw)


Hallo All!

The Compaq cxx compiler (version 6.4, but olders had it as well) on 
Tru64 has the following very annoying feature: if I do

#include "filename.h"

and there is a file called "filename.cc", the compiler silently 
includes "filename.cc" in addition to filename.h into my compilation 
unit, in situations where the template instantiation code thinks that 
this might be useful. 

Is there *any* way to turn this annyoing feature off, other than 
renaming filename.cc to a name where the Compiler will not find it?

I frequently tend to define longer template functions or templated 
class member functions not in a .h file, but in a .cc file, to keep the 
.h file short, and only place the declaration in the .h file. Then, of 
course, I have to explictly instantiate those functions for all 
template parameters that I intend to use in that separate .cc file and 
include that separate .cc file into the link process. At least that is 
what I have to do on all other compilers. But it is OK for me, I mainly 
use templates as a convience (i.E. having the same code for e.g. 2D and 
3D problems) and know which template parameters I will be using.

However, Compaq cxx tries to be smart and treat filename.cc as part of 
the filename.h header file so that the class could be used even with 
template parameters that I have not forseen.

However this breaks everything in my case because then those template 
functions will have an instance both in filename.o and in the object 
file of the compilation unit that included filename.h (e.g. test.o), 
and then the link step will fail.

Now of course I could modify my makefiles to NOT link filename.o in 
case when Compaq cxx is used, but then a) I would further have to tear 
filename.cc apart (it also contains non-templated functions), and b) I 
think that this behaviour of Compaq cxx might be friendly for beginner 
programmers, but really it is bullshit because I absolutely DON'T want 
the compiler to #include files that I did not tell it to include.

The problem can even be verified when just running cxx -E, there you 
will see that the preprocessor (or whatever, maybe a preprocessing 
template instantiator) has placed the contents of filename.cc into the 
compilation unit in addition to filename.h.

If it is of interest I could boil this down to a small testcase and 
send it to an interested cxx developer.

Viele Gr��e,
Tobias



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-06-27 10:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-06-18 19:40 cxx annoyance Tobias Ernst
2001-06-19  2:30 ` Mark Garrett
2001-06-19  8:50   ` Tobias Ernst
2001-06-19  6:02 ` Pentyern
2001-06-19  8:51   ` Tobias Ernst
2001-06-19 15:56     ` Pentyern
2001-06-19 19:29     ` Tim Mooney
2001-06-19  7:24 ` Wolfram Klaus
2001-06-19  8:54   ` Tobias Ernst
2001-06-27 10:53   ` Tobias Ernst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox