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 6561513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:35:49+00:00 2026-05-25T13:35:49+00:00

C++ is still an evolving language and new features are being added to it

  • 0

C++ is still an evolving language and new features are being added to it over the years.

One feature that I miss badly in C++ is a proper module concept: the current approach using header files (where you use a conditional #define to make sure that the header is not included twice) seems definitely unsatisfactorily to me.

For example, in my project we have the problem that we have too many “#include”‘s in many source files, making the compilation time unnecessarily long: it takes 45 minutes to build our product, using Incredibuild, i.e. using at least 10 cores in parallel. Therefore, we have to spend a lot of time cleaning up files manually, i.e. removing includes to check if they are really needed.

I think it would be very useful to have a module concept that makes it possible to

  1. separate clearly the interface from the implementation of a module;
  2. compile the interface and the body of a module separately (currently .h files are compiled again and again each time they are included in other files): a tool could then read the compiled interface and tell what types, functions, classes it exports;
  3. write tools for automatically rearranging imports more easily (e.g. with Java / Eclipse it is possible to rearrange all the imports of a file automatically).

Do you think that it is possible to define such a module concept and integrate it into C++ or would that be too complex? Do you know of any efforts in this direction?

EDIT

Thanks for the suggestion regarding precompiled headers. I will try it out if possible (We use Visual Studio 2008).
Maybe we are using header files in the wrong way(?) We use one header file for each class. Then we have a cpp file with the class implementation. Often we end up with cpp files that include 30, 40 header files. When we change the cpp file, some includes are not needed any longer, but it is difficult to find out which ones. This is partly related to the fact that header files include other header files.

We spend too much time rearranging the imports and it seems there doesn’t exist a tool that can do this automatically. It would save us a lot of time.

  • 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. Editorial Team
    Editorial Team
    2026-05-25T13:35:50+00:00Added an answer on May 25, 2026 at 1:35 pm

    C++ is still an evolving language and new features are being added to
    it as part of the C++0x development.

    The C++11 standard has already been approved and published, so no more features are being added to it. Not for at least another few years.

    One feature that I miss badly in C++ is a proper module concept: the
    current approach using header files (where you use a conditional
    #define to make sure that the header is not included twice) seems
    definitely unsatisfactorily to me.

    Some compilers support #pragma once to avoid having to write the include guards, but it is non-standard as far as I know. There are situations where you don’t want include guards; Boost.Preprocessor is an example of a library with some headers that intentionally don’t have include guards.

    For example, in my project we have the problem that we have too many
    “#include”‘s in many source files, making the compilation time
    unnecessarily long: it takes 45 minutes to build our product, using
    Incredibuild, i.e. using at least 10 cores in parallel. Therefore, we
    have to spend a lot of time cleaning up files manually, i.e. removing
    includes to check if they are really needed.

    Stroustrup has an FAQ entry on compile-time slowness. Also read up on GotW article #7 about including header files. It’s highly likely that you’re including way more files than necessary. For example, you may be able to get away with forward declarations. If you have huge header files, you may try splitting them up so that your sources include only the declarations you really need. It may be just a matter of your file structure not being conducive to fast compiles.

    1.separate clearly the interface from the implementation of a module;

    We have the PIMPL idiom (also known as a compilation firewall) for this. And even without it, I don’t have any trouble putting the implementation in the .cpp file and the interface in the .h file (even though it’s not a “pure” interface).

    2.compile the interface and the body of a module separately
    (currently .h files are compiled again and again each time they are
    included in other files): a tool could then read the compiled
    interface and tell what types, functions, classes it exports;

    Some compilers support precompiled header files that you can take advantage of.

    3.write tools for automatically rearranging imports more easily.

    I don’t understand what you mean by this.

    Do you think that it is possible to define such a module concept and
    integrate it into C++ or would that be too complex? Do you know of any
    efforts in this direction?

    Believe it or not, there is a proposal to add some kind of module concept to C++, but it hasn’t been accepted into C++11 due to time constraints (they were working and reviewing other proposals like rvalue references, which in my opinion, is much more important). It might be included in the next version or update of the C++ standard.

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

Sidebar

Related Questions

I've got an app that is just over 1yr old but it still evolving
Still new to Objective C, and I'm having some trouble that I just can't
still new to the world of linq, and i need some help flatening a
Still a bit new to Linq. This is driving me nuts. I want to
still new to XML parsing with the iphone so i have a few questions.
Still trying to get the navigation control of a new site working the way
Still very new to Rails. How do I call my method in calltwitter.rb file
Still a newbie here, forgive me. I'm trying to make a button that will
I'm an experienced Java programmer that for the last two years have programmed for
Still new to Rails. I'm certain there's a naming convention for what I'm trying

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.