From: The Math Doctor on
I'd like to see a good step-by-step guide to using header files. I've
gotten mine to run, but only after lots of pleading and coaxing. The
reason they run the hundredth time is as obscure as the reason they
hadn't the previous ninety-nine.

I'm particularly interested in Bloodshed Dev-C++, but any other IDE
would interest me.
From: Richard Heathfield on
The Math Doctor wrote:
> I'd like to see a good step-by-step guide to using header files. I've
> gotten mine to run,

Header files don't "run". They contain interface information for a module.

As a basic rule of thumb, headers should contain (more or less in this
order, except for comments, of course):

(a) comments,
(b) preprocessor directives,
(c) type definitions,
(d) function prototypes, and
(e) NOTHING ELSE.

When you have lots of experience, and after lots of soul-searching, you
might consider allowing yourself the luxury of an occasional extern
declaration or even some static const data - but a couple of years
without such indulgences will do your programming discipline no end of good.


> but only after lots of pleading and coaxing. The
> reason they run the hundredth time is as obscure as the reason they
> hadn't the previous ninety-nine.

To give you detailed help, we'll need detailed code.

> I'm particularly interested in Bloodshed Dev-C++, but any other IDE
> would interest me.

The IDE doesn't really matter. If you know the rules of the language,
the IDE should cause you (almost) no problems at all.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
From: Paul Bibbings on
Richard Heathfield <rjh(a)see.sig.invalid> writes:

> The Math Doctor wrote:
> Header files don't "run". They contain interface information for a module.
>
> As a basic rule of thumb, headers should contain (more or less in this
> order, except for comments, of course):
>
> (a) comments,
> (b) preprocessor directives,
> (c) type definitions,
> (d) function prototypes, and
> (e) NOTHING ELSE.

Also, don't forget include guards.

// file: my_header.hpp

#ifndef MY_HEADER_HPP_
#define MY_HEADER_HPP_

// header code here

#endif /* MY_HEADER_HPP_ */
From: Richard Heathfield on
osmium wrote:

<snip>

> I have what I think is a good sample of a very good h file skeleton in my
> voluminous file system. Alas, I can not find it.

Have a look in the cupboard. That's one very common stamping ground for
skeletons.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
From: Richard Heathfield on
Paul Bibbings wrote:
> Richard Heathfield <rjh(a)see.sig.invalid> writes:
>
>> The Math Doctor wrote:
>> Header files don't "run". They contain interface information for a module.
>>
>> As a basic rule of thumb, headers should contain (more or less in this
>> order, except for comments, of course):
>>
>> (a) comments,
>> (b) preprocessor directives,
>> (c) type definitions,
>> (d) function prototypes, and
>> (e) NOTHING ELSE.
>
> Also, don't forget include guards.

Right. They are covered in (b), above.

<good example snipped>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within