difference in header files

W

Walter Roberson

what's the difference between a .h and a .hpp file

C doesn't promise that a .hpp file can be #include'd -- unique
mappings are promised only for (up to) 6-characters followed by a
single character.
Also please tell me something about .rh files

As per above, C doesn't promise that .rh files are usable either.


Perhaps you are thinking of some other programming language, such
as C++?
 
K

Kulka

Pieknego dnia Wed, 10 Aug 2005 01:22:17 +0530,
osobnik Pradyut napisa³(a):
what's the difference between a .h and a .hpp file
..hpp are header files for c++, while h for c
 
E

E. Robert Tisdale

Pradyut said:
what's the difference between a *.h and a *.hpp file

These file extensions are arbitrary but customary.
You can include files with *any* file name extension or none at all.
Also please tell me something about .rh files

Which is what appears to have been done here.

The *.h extension was added to [UNIX] file names
to suggest that the file was a C *header* file
instead of a C *source* file.
The *.hpp file name extension is sometimes used
to distinguish C++ header files from C header files.

A header file is a file that is included near the top (head)
of a translation unit (source file) or another header file.
It may contain *any* valid C code
but header files are commonly used
to introduce a module interface into a translation unit.
The module interface contains C preprocessor macro definitions,
type definitions, constant definitions,
function and variable declarations
that do not by themselves require the compiler to emit code
or reserve space for objects.
 
M

Mark McIntyre

what's the difference between a .h and a .hpp file

this would be something specific to your implementation or company
style. C doesn't place any particular requirements on the file
extensions - remember that its only MSDOS and its children that think
the extension is an indication of the file's format, most other OSen
find it more useful to store that info elsewhere...

<ot>
some people like to use hpp for C++ includes and h for C ones.
Also please tell me something about .rh files

Something else system-specific. Possibly resource includes? Ask in a
newsgroup specialising in your compiler.
 
W

Walter Roberson

These file extensions are arbitrary but customary.
You can include files with *any* file name extension or none at all.

C89 doesn't promise that it will be able to uniquely locate files
whose extension is more than 1 character long. (C89 doesn't want to
impose any filesystem semantics onto freestanding implementations.)
 
R

Robert Gamble

Walter said:
C89 doesn't promise that it will be able to uniquely locate files
whose extension is more than 1 character long.

Yup, the same stands for C99 as well. Not only that, the 1 character
must be a *letter* to qualify for this this guarantee. Additionally,
since the implementation may ignore the case of filenames in #include
directives, it need not differentiate between header.h and header.H (or
HEADER.H for that matter).

Robert Gamble
 
J

Jack Klein

C doesn't promise that a .hpp file can be #include'd -- unique
mappings are promised only for (up to) 6-characters followed by a
single character.

Note that this is, and has been since 1999:

"The implementation shall provide unique mappings for sequences
consisting of one or more letters or digits (as defined in 5.2.1)
followed by a period (.) and a single letter. The first character
shall be a letter. The implementation may ignore the distinctions of
alphabetical case and restrict the mapping to eight significant
characters before the period."

So it now 8 characters, and the standard now includes three standard
headers that have more than six significant characters before the
period: <complex.h>, <stdbool.h>, and <inttypes.h>

Other than the standard headers, C places no restrictions at all on
the contents of <h_char_sequence> or "q_char_sequence" in a #include
directive. If between them the implementation and underlying platform
map them into a file "that can be processed by the application", it
causes the replacement of the directive by the entire contents of the
file.

If the sequence does not match a standard header and does not map to
the name of a file that can be processed by the application, it is a
constraint error and a diagnostic is required.
As per above, C doesn't promise that .rh files are usable either.


Perhaps you are thinking of some other programming language, such
as C++?

I don't really see what C++ has to do with it.

Even under MS-DOS, in fact even under CP/M 80, I could expect:

#include "filename.rh"

....to do what I wanted, assuming there was a file named filename.rh in
the implementation-defined search path. Although AFAIK there was
never a C90 conforming implementation for CP/M 80.
 
J

Jack Klein

C89 doesn't promise that it will be able to uniquely locate files
whose extension is more than 1 character long. (C89 doesn't want to
impose any filesystem semantics onto freestanding implementations.)

Where does C89, or any other version, mention an implementation that
runs (as opposed to builds code for) a free-standing environment?

No environment for translators is mentioned at all. The distinction
between hosted and free-standing environments has to do with
execution, not translation.
 
L

Lawrence Kirby

Where does C89, or any other version, mention an implementation that
runs (as opposed to builds code for) a free-standing environment?

No environment for translators is mentioned at all. The distinction
between hosted and free-standing environments has to do with
execution, not translation.

The standard sepcifies hosted and freestanding implementations as well as
execution environments. This is highly relevant to translation, for
example #include <stdio.h> may legitimately fail during translation on a
freestanding implementation.

Lawrence
 
J

James McIninch

<posted & mailed>

A ".h file" is a file using a common convention for naming header files for
C libraries. As far as the C language is concerned, there's no such thing
as a .hpp or .rh file.
 
D

Dave Thompson

this would be something specific to your implementation or company
style. C doesn't place any particular requirements on the file
extensions - remember that its only MSDOS and its children that think
the extension is an indication of the file's format, most other OSen
find it more useful to store that info elsewhere...
I know no OS that itself relies on the extension, except in a CI/shell
that can be overridden or at least adjusted to some extent. But there
certainly have been many before and other than MS that supported an
extension or equivalent field that most or all vendor-supplied utility
software _did_ rely on: at least RT-11, RSX-11, TOPS-10 and -20 -- and
(nonvendor) ITS to some extent, VMS, I think AOS/VS, and VM/CMS. And
CP/M, which is no child of MSDOS although a case can be made for the
inverse. Even in Unix _some_ utility software relies on extensions.

- David.Thompson1 at worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top