Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. My Great Idea

My Great Idea

Scheduled Pinned Locked Moved The Lounge
linuxhelptutorial
21 Posts 12 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B BernardIE5317

    I had a great idea this morning upon waking up. I don't know how to figure out which #include's are needed to compile any particular source other than tedious error prone inspection followed by numerous compilations #include'ing one by one any file to resolve the latest error. The great idea was to automate the process by compiling every possible combination [1...40] subsets of the 40 #include's in my project and settling on the combination with the smallest number needed for an error free compile. This could easily be done via awk to automate the insertion of the #include statements. However a calculation of the number of possible combinations of 40 files in every possible subset number resulted in "inf" appearing on my monitor so I guess it won't work at least not on my pig of a machine. I guess I will have to wait for entangled bits.

    K Offline
    K Offline
    k5054
    wrote on last edited by
    #12

    I'm sure there's tools to do this. Maybe something like CPPDepend? [Dependency Graph](https://www.cppdepend.com/Doc\_VS\_Arch) That seems to be a commercial tool, I've not used it, so I can't comment on whether it actually works or not, but it seems like it might give you what you're looking for. Maybe search results for "C++ include dependency graph" or similar might lead you to what you're looking for.

    Keep Calm and Carry On

    1 Reply Last reply
    0
    • B BernardIE5317

      Thank you for the clarification. The last statement confuses me. Should it not be "C should include A" as C is using an identifier defined in A.

      Greg UtasG Offline
      Greg UtasG Offline
      Greg Utas
      wrote on last edited by
      #13

      Quite right. I'll fix it.

      Robust Services Core | Software Techniques for Lemmings | Articles
      The fox knows many things, but the hedgehog knows one big thing.

      <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
      <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

      1 Reply Last reply
      0
      • B BernardIE5317

        I had a great idea this morning upon waking up. I don't know how to figure out which #include's are needed to compile any particular source other than tedious error prone inspection followed by numerous compilations #include'ing one by one any file to resolve the latest error. The great idea was to automate the process by compiling every possible combination [1...40] subsets of the 40 #include's in my project and settling on the combination with the smallest number needed for an error free compile. This could easily be done via awk to automate the insertion of the #include statements. However a calculation of the number of possible combinations of 40 files in every possible subset number resulted in "inf" appearing on my monitor so I guess it won't work at least not on my pig of a machine. I guess I will have to wait for entangled bits.

        M Offline
        M Offline
        Member 9167057
        wrote on last edited by
        #14

        This bloody #include hell is huge reason why I'm looking forward to widespread standard module support. Until then, I combine all the external includes into one header & include that.

        1 Reply Last reply
        0
        • B BernardIE5317

          I had a great idea this morning upon waking up. I don't know how to figure out which #include's are needed to compile any particular source other than tedious error prone inspection followed by numerous compilations #include'ing one by one any file to resolve the latest error. The great idea was to automate the process by compiling every possible combination [1...40] subsets of the 40 #include's in my project and settling on the combination with the smallest number needed for an error free compile. This could easily be done via awk to automate the insertion of the #include statements. However a calculation of the number of possible combinations of 40 files in every possible subset number resulted in "inf" appearing on my monitor so I guess it won't work at least not on my pig of a machine. I guess I will have to wait for entangled bits.

          F Offline
          F Offline
          Fueled By Decaff
          wrote on last edited by
          #15

          Does the order of the includes matter? If not you could include all of them to check the project compiles, then remove them one by one and adding them back if removing them breaks the compile. 40! is 8.1591528e+47 according to Google. That would take a while to work through.

          1 Reply Last reply
          0
          • B BernardIE5317

            I had a great idea this morning upon waking up. I don't know how to figure out which #include's are needed to compile any particular source other than tedious error prone inspection followed by numerous compilations #include'ing one by one any file to resolve the latest error. The great idea was to automate the process by compiling every possible combination [1...40] subsets of the 40 #include's in my project and settling on the combination with the smallest number needed for an error free compile. This could easily be done via awk to automate the insertion of the #include statements. However a calculation of the number of possible combinations of 40 files in every possible subset number resulted in "inf" appearing on my monitor so I guess it won't work at least not on my pig of a machine. I guess I will have to wait for entangled bits.

            S Offline
            S Offline
            Samuel Ervin
            wrote on last edited by
            #16

            Not a bad idea, but how do you exclude circular dependencies from cropping up in this case. Not all of them are caught at compile time which you could run the risk of introducing them into your application with a just get it to compile mindset.

            1 Reply Last reply
            0
            • B BernardIE5317

              I had a great idea this morning upon waking up. I don't know how to figure out which #include's are needed to compile any particular source other than tedious error prone inspection followed by numerous compilations #include'ing one by one any file to resolve the latest error. The great idea was to automate the process by compiling every possible combination [1...40] subsets of the 40 #include's in my project and settling on the combination with the smallest number needed for an error free compile. This could easily be done via awk to automate the insertion of the #include statements. However a calculation of the number of possible combinations of 40 files in every possible subset number resulted in "inf" appearing on my monitor so I guess it won't work at least not on my pig of a machine. I guess I will have to wait for entangled bits.

              P Offline
              P Offline
              PhilipOakley
              wrote on last edited by
              #17

              You could try the technique used in the Git project. Firstly, they do have two two top level `.h` files that are always included as the first lines in any other file that will need includes. This provides a level commonality across the project, and a consistent inclusion order. Secondly, and slightly more important for you, is that all the included `.h` files have a preamble/suffix of:

              #ifndef _H
              #define _H */

              Thus stuff is included only once and a hierarchy of usage is created. Add

              #else /* warnings */

              for extra feedback and local tastes.

              1 Reply Last reply
              0
              • B BernardIE5317

                I had a great idea this morning upon waking up. I don't know how to figure out which #include's are needed to compile any particular source other than tedious error prone inspection followed by numerous compilations #include'ing one by one any file to resolve the latest error. The great idea was to automate the process by compiling every possible combination [1...40] subsets of the 40 #include's in my project and settling on the combination with the smallest number needed for an error free compile. This could easily be done via awk to automate the insertion of the #include statements. However a calculation of the number of possible combinations of 40 files in every possible subset number resulted in "inf" appearing on my monitor so I guess it won't work at least not on my pig of a machine. I guess I will have to wait for entangled bits.

                M Offline
                M Offline
                Matthew Barnett
                wrote on last edited by
                #18

                Instead of inserting until there are no errors, have you tried deleting until there's an error and then re-inserting it? When you can't delete any without causing an error, you've finished.

                1 Reply Last reply
                0
                • B BernardIE5317

                  I had a great idea this morning upon waking up. I don't know how to figure out which #include's are needed to compile any particular source other than tedious error prone inspection followed by numerous compilations #include'ing one by one any file to resolve the latest error. The great idea was to automate the process by compiling every possible combination [1...40] subsets of the 40 #include's in my project and settling on the combination with the smallest number needed for an error free compile. This could easily be done via awk to automate the insertion of the #include statements. However a calculation of the number of possible combinations of 40 files in every possible subset number resulted in "inf" appearing on my monitor so I guess it won't work at least not on my pig of a machine. I guess I will have to wait for entangled bits.

                  2 Offline
                  2 Offline
                  240DL
                  wrote on last edited by
                  #19

                  When I want to debug things related to header inclusion, I typically run the compiler in preprocessor-only mode and scan the output. vc /P ... or ... gcc -E You've tried this? The preprocessed output sometimes shows some interesting things and might be good input for a tool chain. -- Matt

                  1 Reply Last reply
                  0
                  • H honey the codewitch

                    I feel like such a tool would belong in the weird and the wonderful. I hate to say this, but if your includes are so heavily dependent on ordering you are almost certainly due for a restructure of your code. For example, it might be better to do the includes as more of a tree in terms of what includes what than you currently have it. There are a number of ways to deal with it but it all has to do with structure. Edit: I'm not saying this is certainly the issue in your case. It just smells from here. My spidey sense is tingling.

                    To err is human. Fortune favors the monsters.

                    C Offline
                    C Offline
                    charlieg
                    wrote on last edited by
                    #20

                    "my spider sense..." lol. well put

                    Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                    H 1 Reply Last reply
                    0
                    • C charlieg

                      "my spider sense..." lol. well put

                      Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                      H Offline
                      H Offline
                      honey the codewitch
                      wrote on last edited by
                      #21

                      technically it was "spidey" - comes from the old spiderman comics. :)

                      To err is human. Fortune favors the monsters.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups