What file extension should I use?

This is a discussion on What file extension should I use? within the C++ Programming forums, part of the General Programming Boards category; H or HPP? This has been driving me crazy!...

  1. #1
    Newbie Programmer
    Join Date
    Oct 2005
    Location
    Montreal, Canada
    Posts
    5

    What file extension should I use?

    H or HPP? This has been driving me crazy!

  2. #2
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    What is the file going to do? (I don't know what .hpp would be...better go look it up I guess )
    There is a difference between tedious and difficult.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,644
    Sounds like the fellow is trying to decide between .h and .hpp for header filename extensions in C++. My own opinion is that it doesnt really matter most of the time, as long as one is consistent.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    I googled them both, and found that .h was for header file (which I knew), but everywhere that had .hpp listed they specifically said "program header." I thought maybe there was a small functional or semanitc difference, but laserlight's post says otherwise. I think it wise to side with laserlight. Is that correct?
    There is a difference between tedious and difficult.

  5. #5
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    The extension can be anything you want, .java, .happy or .bush. The file is just copy-and-pasted into the source file that includes it.

    Most people use .h is used for C headers, and .hpp for C++ headers. For example, the boost C++ library uses .hpp

  6. #6
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    Is either one defined in the C++ standard? (I would look it up but I don't know where...)
    There is a difference between tedious and difficult.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    A quick check says no, although the standard does use .h in its examples.

  8. #8
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Headers for the standard library for C++ don't have an extension. E.g. <algorithm> <cstdlib> <cstdio> <vector>. Other than that, I don't think there are any restrictions for your own headers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21