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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:56:46+00:00 2026-06-09T08:56:46+00:00

Based on my understanding, the chief benefits of creating a program with multiple compilation

  • 0

Based on my understanding, the chief benefits of creating a program with multiple compilation units are reusability of components and shorter compile times when incorporating small changes.

I also think (possibly wrongly) that there is a penalty associated with this, in that functions which are defined in their own compilation units cannot be declared as “inline”.
[I recognize that this keyword does not actually force the compiler to inline-expand functions, but my understanding is that it gives the compiler more flexibility to optimize, and is therefore worth including wherever possible.]

So far so good?

My real question is whether the cost/benefit analysis still favours multiple compilation units when the program is solving a complicated modelling problem, and is required to iterate through its main loop for months on a cluster in order to generate useful output.

Say a multi-compilation unit program takes a few minutes to compile while the same program re-configured as a single compilation unit takes a few hours to compile… if the single compilation unit declares all functions as inline and thus presents more optimization opportunities, it seems reasonable to me to expect that execution time could decrease by a few percent, more than making up for the extra compile time.

Are there good rules of thumb for situations like this, or is it heavily situation-dependent?

  • 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-06-09T08:56:47+00:00Added an answer on June 9, 2026 at 8:56 am

    As already stated by others, the main benefit of decomposing a program into different compilation units is readability.
    Shorter compilation times is somehow a nice side-effect of the idea.

    If you care about inlining, you can resort to Link Time Code Generation and Link-Time Optimization. The combination of program decomposition into compilation units and LTO looks like the ideal solution, although it is not clear if the kind of optimizations performed by a compiler when the full definition of the function is available could be performed by LTO.
    For example, I don’t know if LTO could support return-value optimization in C++, since it is something done at an high level of abstraction. Performance tests are needed.
    (Edit: RVO is performed even in absence of LTO and advanced tricks like these, at least on gcc and clang [I tried]. Most probably, this optimization is performed by changing the ABI of the function, which takes a “hidden pointer” to the object which has to be constructed and returned in the function.)

    A third solution which could be worth investigating is to use something like sqlite amalgamation, a process of putting different compilation units into one giant .c file.
    Looks like something which requires a kinda heavy user-made infrastructure, although.

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

Sidebar

Related Questions

Based on my understanding, SerializableAttribute provides no compile time checks, as it's all done
Does Gmail support RFC 821? I know it is using ESMTP. Based on understanding
Based on my understanding of the Java language, static variables can be initialized in
Normally ( Based on my understanding ) i have to follow a lot of
My understanding is that Java's implementation of regular expressions is based on Perl's. However,
I'm having difficulty understanding variable shadowing in JavaScript based on scopes. Consider this small
This question probably is based on my lack of understanding of the role of
I've been working with some ExternalDataExchange - based communication in WF recently. My understanding
Based on my current understanding of hashes in Perl, I would expect this code
So my understanding of currying (based on SO questions) is that it lets you

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.