Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > c++ standard and file extenstions (.hpp, .H, .hxx)

Reply
Thread Tools

c++ standard and file extenstions (.hpp, .H, .hxx)

 
 
whit
Guest
Posts: n/a
 
      03-19-2009
Is anyone aware of language in the standard that guarantees header
files with any extension will be allowed in an #include statement?

The issue is that I'm writing a few "add-on" packages for the R
language. However, the R project rejects any header files that do not
have a .h extension on the basis of compiler portability. i.e. we know
that gcc accepts the .hpp files, but we don't know if other compilers
accept those file extensions.

However, if the standard guarantees that any extensions for header
files can be allowed that is a strong argument for R to change its
policy.

Thanks,
Whit
 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      03-19-2009
On Mar 19, 1:35 pm, Victor Bazarov <(E-Mail Removed)> wrote:
> whit wrote:
> > Is anyone aware of language in the standard that guarantees
> > header files with any extension will be allowed in an
> > #include statement?


> There is nothing in the Standard governing the "allowed" or
> "prohibited" file name extension AFA textual inclusion is
> concerned.


That's not quite true. A conformant implementation is required
to recognize the standard headers in an <...> include (but not
in a "..." include). Also, the standard requires that" The
implementation provides unique mappings for sequences consisting
of one or more nondigits or digits (2.10) followed by a period
(.) and a single nondigit. The first character shall not be a
digit. The implementation may ignore the distinctions of
alphabetical case." (The C standard restricts this to 8
characters before the period. In practice, I don't know of any
C++ implementation which is conform, but all conform to the C
standard.)

> The standard headers are all known, and they aren't
> necessarily files. It is up to the implementation in what
> form it chooses to have those headers. As to your own, you
> probably can have anything there, given that the character
> sequence between '<' and '>' (or in double quotes) does not
> violate the requirements for the preprocessor directive.


The characters between the <...> and the "..." in a return
follow special rules (and the rules aren't necessarily the same
in both cases). What is legal depends on the implementation.
All the standard reuires is that alphanumeric characters are
accepted. In practice, there are probably a few more that are
safe. (I regularly use '/' as a directory separator. But
admittedly, I'm not concerned with portability beyond Unix and
Windows.)

> > The issue is that I'm writing a few "add-on" packages for
> > the R language. However, the R project rejects any header
> > files that do not have a .h extension on the basis of
> > compiler portability. i.e. we know that gcc accepts the .hpp
> > files, but we don't know if other compilers accept those
> > file extensions.


> That's up to the compiler. The standard headers, if they are
> files, do not have any extensions. The old C headers do, it's
> ".h", and it's still supported by the C++ Standard, but that's
> an *inclusive* requirement, not an *exclusive* one.


In practice, any sequence of alphanumeric characters will work,
at least up to three. What's uncertain is whether case is
distinctive---historically, a lot of C++ headers used .H, which
is confonded with .h on some systems.

> > However, if the standard guarantees that any extensions for
> > header files can be allowed that is a strong argument for R
> > to change its policy.


> There is no such explicit guarantee. It's up to the
> implementation.


See above. But in practice, up to three alphanumeric characters
after the . will not cause problems.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect a "system" standard output and standard error to avariable (Linux) Venks Ruby 5 12-06-2007 12:21 AM
add pexpect to the standard library, standard "install" mechanism. funkyj Python 5 01-20-2006 08:35 PM
Abstract Class Extenstions Not exactly working as I would expect. Michael Boocher via JavaKB.com Java 8 05-30-2005 03:25 PM
How standard is the standard library? steve.leach Python 1 04-18-2005 04:07 PM
REGEX (Not allowing file extenstions) or the dot Perl Misc 8 10-05-2003 06:07 AM



Advertisments