Newsgroups: comp.lang.c++
Path: utzoo!utgpu!cunews!csi.uottawa.ca!news
From: hitz@sim5.csi.uottawa.ca (Martin Hitz)
Subject: Re: A GNU Makefile (was: ... header files **and** inline management)
Message-ID: <1991Feb18.225005.5119@csi.uottawa.ca>
Sender: Martin Hitz 
Nntp-Posting-Host: sim5
Organization: University of Ottawa
References: <3787@lupine.NCD.COM> <1991Feb11.081550.18057@eua.ericsson.se> <3943@lupine.NCD.COM>
Distribution: World
Date: Mon, 18 Feb 91 22:50:05 GMT

In article <3943@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes:
>In article <1991Feb11.081550.18057@eua.ericsson.se> euamts@eua.ericsson.se (Mats Henricson) writes:
>>In article <1991Feb5.180503.24515@mathcs.sjsu.edu> horstman@mathcs.sjsu.edu (Cay Horstmann) writes:
>>>
>>>I agree 100% with Ron that HEADER FILES SHOULD BE AUTOMATICALLY GENERATED.
>>
>>Maybe I've misunderstood the whole thing...
>
>Perhaps you have.
>
>>... but I think this is a bad idea.
>>The most important thing with a C++ class is its interface to the outside
>>world, i.e. the header file. That is why I design the header file first,
>>and then the .cc-file.
>
>And you never go back and make any changes to the "interface" part once
>you have written it for the first time!?!?!?!
>
>I'd like to meet you someday.  I've never had the opportunity to meet a
>"perfect" programmer before!

Neither have I. During early stages of the development process,
when the final shape of .h files is not yet totally well defined, we
simulate our .h files with a slightly elaborated version of the following
mechanism:

----------------- file x.h (preliminary version):
#ifndef X_H
#define X_H
#include "x.cc"
#endif
----------------- eof x.h
----------------- file x.cc (preliminary version):
// #include "x.h" - will be activated later 

class X {
 public:
	X();
};

extern X x;

#ifndef X_H  /* implementation part #1 */
X::X()
{
	/****************/
}

X x;
#endif  

class Y {
/***** etc. ****/
};

#ifndef X_H /* implementation part #2 */
/* Y implementation */
#endif
----------------- eof x.cc

Once the interface has stabilized, the real x.h is generated (by hand,
by sed, by awk, by the preprocessor ...) and the x.cc is shrunk.
Of course, this method needs a tailored makefile, too, where every .h
dependency is replaced by a corrseponding .cc dependency.

Martin (hitz@csi.UOttawa.CA)
