Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 118283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:28:13+00:00 2026-05-11T03:28:13+00:00

I’m playing around with gmock and noticed it contains this line: #include <tuple> I

  • 0

I’m playing around with gmock and noticed it contains this line:

#include <tuple> 

I would have expected tuple.h.

When is it okay to exclude the extension, and does it give the directive a different meaning?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:28:13+00:00Added an answer on May 11, 2026 at 3:28 am

    The C++ standard headers do not have a ".h" suffix. I believe the reason is that there were many, different pre-standard implementations that the standard would break. So instead of requiring that vendors change their existing "iostream.h" (for example) header to be standards compliant (which would break their existing user’s code), the standards committee decided that they’d drop the suffix (which, I believe no then existing implementation had already done).

    That way, existing non-standard programs would continue to work using the vendor’s non-standard libraries. When the user wanted to make their programs standards-compliant, one of the steps they would take is to change the "#include" directive to drop the ".h" suffix.

    So

    #include <iostream>     // include the standard library version #include <iostream.h>   // include a vendor specific version (which by                          //      now might well be the same) 

    As other answers have mentioned, writers of non-standard libraries may choose either naming convention, but I’d think they would want to continue using ".h" or ".hpp" (as Boost has done) for a couple of reasons:

    1. If and when the library gets standardized, the standard version won’t automatically override the previous, non-standard one (causing broken user code in all likelihood).
    2. It seems to be a convention (more or less) that headers without a suffix are standard libraries, and those with a suffix (other than the C compatibility headers) are non-standard.

    Note that a similar problem happened when the committee went to add hash maps to the STL – they found that there are already many (different) hash_map implementations that exist, so instead of coming up with a standard one that breaks a lot of stuff out there today, they call the standard implementation "unordered_map". Namespaces were supposed to help prevent this type of jumping through hoops, but it didn’t seem to work well enough (or be used well enough) to allow them to use the more natural name without breaking a lot of code.

    Note that for the ‘C’ headers, C++ allows you to include either a <cxxxxxx> or <xxxxxx.h> variant. The ones that start with ‘c’ and have no ".h" suffix put their declarations in the std namespace (and possibly also in the global namespace); the ones with the ".h" suffix put the names in the global namespace (and possibly also in the std namespace).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.