Thread: What file extension should I use?

  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
    28,413
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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,366
    A quick check says no, although the standard does use .h in its examples.

  8. #8
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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, 02:58 AM