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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:52:40+00:00 2026-06-07T01:52:40+00:00

I was reading through Automatic Dependency Generation in the make manual and I can’t

  • 0

I was reading through Automatic Dependency Generation in the make manual and I can’t figure out why this functionality is needed. The project that I am working on and I started writing from scratch is structured like this:

  • each unit (library) has it’s own folder
  • each .cpp file should include a single .h file with the same name from the same directory. OK, this rule can be a bit too restrictive, like in the case of circular dependencies, in which case I may include another .h file, just as described in the next rule
  • when including other headers in a .h file, always use paths relative to the root directory of the project, if the dependency is located in another unit (library). Otherwise, just include the name of the file.

In the makefile, I pass -I . to the compiler. When it encounters a .cpp file in directory X, it will search for the .h file in the same directory (or in the . directory). When parsing the .h file, it will encounter includes relative to the . folder, so it will know where to look for them.

Now, why would anybody want to generate a list of dependencies with the -M flag and mess with sed to produce an obscure .d file (dependencies fie) if code can be structured like I described above? I don’t see the point of generating the specific list of dependencies from a code file.

  • 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-07T01:52:42+00:00Added an answer on June 7, 2026 at 1:52 am

    Because in practice, each source file will depend on multiple header files. If you don’t recompile the source file each time any of those headers changes, there is a good chance you will end up with an inconsistent binary.

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

Sidebar

Related Questions

Reading through this excellent article about safe construction techniques by Brain Goetz, I got
It's clear from reading through threads that I can call a PHP function using
I'm currently reading through this jquery masking plugin to try and understand how it
Reading through the documentation for powershells add-type it seems you can add JScript code
Reading through the C specs I found this function: double remquo(double x, double y,
Reading through this question on multi-threaded javascript, I was wondering if there would be
Reading through a paper for the ARM Cortex-M3 CPU I found this line confusing:
Reading through the assembly GCC generates for C files in my project, I notice
Reading through the following instruction table manual I see that integer multiplication is often
Reading through the Backbone.js source code, I saw this: validObj[attr] = void 0; What

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.