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. General Programming
  3. C / C++ / MFC
  4. #include - again

#include - again

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
11 Posts 5 Posters 66 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.
  • L Lost User

    I rely on "intelisense" to help me to add CORRECT #include header file. It sort of works in "left to right " fashion . If I need to add "header_.h" file I have to step thru all options BEFORE I have "header_.h " option. #include "../ now intlesence gives all options after "/". The "problem is " - until CORRECT , valid option is presented and selected I still have no way to see if it actually have an option to select desired header. It would be nice to have option to determine required path BEFORE going thru the intelisense steps. Sort of in reverse direction, opposite intelisense way. Is there?

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    Since you are using #include " ... (double quotes) rather than #include < ... (angle brackets), you should know what the path is, as you are referring to local headers. But you could simplify things by adding the required header locations to the list of include directorie for the compiler to search.

    1 Reply Last reply
    0
    • L Lost User

      I rely on "intelisense" to help me to add CORRECT #include header file. It sort of works in "left to right " fashion . If I need to add "header_.h" file I have to step thru all options BEFORE I have "header_.h " option. #include "../ now intlesence gives all options after "/". The "problem is " - until CORRECT , valid option is presented and selected I still have no way to see if it actually have an option to select desired header. It would be nice to have option to determine required path BEFORE going thru the intelisense steps. Sort of in reverse direction, opposite intelisense way. Is there?

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #3

      For standard include files, doc pages for the function usually show what include file to use. For your own, or other dependencies, not much luck. You can try to grep function name in *.h files. Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

      Mircea

      T 2 Replies Last reply
      0
      • Mircea NeacsuM Mircea Neacsu

        For standard include files, doc pages for the function usually show what include file to use. For your own, or other dependencies, not much luck. You can try to grep function name in *.h files. Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

        Mircea

        T Offline
        T Offline
        trønderen
        wrote on last edited by
        #4

        Mircea Neacsu wrote:

        Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

        I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need. I am quite sure that for an example showing significant higher compilation times, you would have to make a system wide search for .h files and include them all in the "uber" file :-) There are other good reasons for avoiding the "uber" approach, though: Pollution of the name space. Not because I worry about symbol table sizes, but about too many symbols being acceptable. Sort of in the same class as languages that doesn't require declaration: If you misspell a name, it is not a misspelling, but creation of a new variable. Or, if your language lets you make local redefinitions of names in an outer scope: Remove the local (re)definition, and your code will reference a completely different variable. The "uber"

        Religious freedom is the freedom to say that two plus two make five.

        1 Reply Last reply
        0
        • Mircea NeacsuM Mircea Neacsu

          For standard include files, doc pages for the function usually show what include file to use. For your own, or other dependencies, not much luck. You can try to grep function name in *.h files. Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

          Mircea

          T Offline
          T Offline
          trønderen
          wrote on last edited by
          #5

          Mircea Neacsu wrote:

          Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

          I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need. I am quite sure that for an example showing significant higher compilation times, you would have to make a system wide search for .h files and include them all in the "uber" file :-) There are other good reasons for avoiding the "uber" approach, though: Pollution of the name space. Not because I worry about symbol table sizes, but about too many symbols being acceptable. Sort of in the same class as languages that doesn't require declaration: If you misspell a name, it is not a misspelling, but creation of a new variable. Or, if your language lets you make local redefinitions of names in an outer scope: Remove the local (re)definition, and your code will reference a completely different variable. The "uber" approach makes available to you a whole lot that you are not aware of, not its origins. You won't have an error message that a declaration is missing. You don't know what you are making use of. One day someone adds a similarly defined function to your project, doing things in a different way, and your code fails ... Ideally, you should know every single instruction your code executes. That is of course impossible; we have to rely on libraries, OS functions etc., but we select them, deliberately and concerned. The "uber" approach invites to introducing a lot of code that is not at all selected, neither deliberately nor concerned, it just is there, ready to manipulate your data in ways that you do not know. Blackboxing principles go both ways: Your class, module, namespace or whatever should not expose more of itself that what is absolutely necessary for others to know. But at the same time: Inside that black box, you should not see more of the environment than absolutely necessary for the blackbox to know. One of the nice features of VS is that it tells when you are using namespaces, but not using any names from them!

          Religious freedom is the freedom to say that two plus two make five.

          Mircea NeacsuM L K 3 Replies Last reply
          0
          • T trønderen

            Mircea Neacsu wrote:

            Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

            I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need. I am quite sure that for an example showing significant higher compilation times, you would have to make a system wide search for .h files and include them all in the "uber" file :-) There are other good reasons for avoiding the "uber" approach, though: Pollution of the name space. Not because I worry about symbol table sizes, but about too many symbols being acceptable. Sort of in the same class as languages that doesn't require declaration: If you misspell a name, it is not a misspelling, but creation of a new variable. Or, if your language lets you make local redefinitions of names in an outer scope: Remove the local (re)definition, and your code will reference a completely different variable. The "uber" approach makes available to you a whole lot that you are not aware of, not its origins. You won't have an error message that a declaration is missing. You don't know what you are making use of. One day someone adds a similarly defined function to your project, doing things in a different way, and your code fails ... Ideally, you should know every single instruction your code executes. That is of course impossible; we have to rely on libraries, OS functions etc., but we select them, deliberately and concerned. The "uber" approach invites to introducing a lot of code that is not at all selected, neither deliberately nor concerned, it just is there, ready to manipulate your data in ways that you do not know. Blackboxing principles go both ways: Your class, module, namespace or whatever should not expose more of itself that what is absolutely necessary for others to know. But at the same time: Inside that black box, you should not see more of the environment than absolutely necessary for the blackbox to know. One of the nice features of VS is that it tells when you are using namespaces, but not using any names from them!

            Religious freedom is the freedom to say that two plus two make five.

            Mircea NeacsuM Offline
            Mircea NeacsuM Offline
            Mircea Neacsu
            wrote on last edited by
            #6

            Your name pollution point is valid. I just said it's "another strategy", I didn't say it's a good strategy :laugh:.

            trønderen wrote:

            I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need.

            Easy: just turn the "uber" in a pre-compiled header and that speeds up things dramatically.

            Mircea

            1 Reply Last reply
            0
            • T trønderen

              Mircea Neacsu wrote:

              Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

              I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need. I am quite sure that for an example showing significant higher compilation times, you would have to make a system wide search for .h files and include them all in the "uber" file :-) There are other good reasons for avoiding the "uber" approach, though: Pollution of the name space. Not because I worry about symbol table sizes, but about too many symbols being acceptable. Sort of in the same class as languages that doesn't require declaration: If you misspell a name, it is not a misspelling, but creation of a new variable. Or, if your language lets you make local redefinitions of names in an outer scope: Remove the local (re)definition, and your code will reference a completely different variable. The "uber" approach makes available to you a whole lot that you are not aware of, not its origins. You won't have an error message that a declaration is missing. You don't know what you are making use of. One day someone adds a similarly defined function to your project, doing things in a different way, and your code fails ... Ideally, you should know every single instruction your code executes. That is of course impossible; we have to rely on libraries, OS functions etc., but we select them, deliberately and concerned. The "uber" approach invites to introducing a lot of code that is not at all selected, neither deliberately nor concerned, it just is there, ready to manipulate your data in ways that you do not know. Blackboxing principles go both ways: Your class, module, namespace or whatever should not expose more of itself that what is absolutely necessary for others to know. But at the same time: Inside that black box, you should not see more of the environment than absolutely necessary for the blackbox to know. One of the nice features of VS is that it tells when you are using namespaces, but not using any names from them!

              Religious freedom is the freedom to say that two plus two make five.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              Sort of in reverse direction, opposite intelisense way.

              Is there?

              concluding from discussion which "went sideways" ( am I allowed to have an opinion ?) there is no such option

              T B 2 Replies Last reply
              0
              • T trønderen

                Mircea Neacsu wrote:

                Another strategy is to use an “uber include” that includes all or a lot of other h files, but it can slow down compilation.

                I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need. I am quite sure that for an example showing significant higher compilation times, you would have to make a system wide search for .h files and include them all in the "uber" file :-) There are other good reasons for avoiding the "uber" approach, though: Pollution of the name space. Not because I worry about symbol table sizes, but about too many symbols being acceptable. Sort of in the same class as languages that doesn't require declaration: If you misspell a name, it is not a misspelling, but creation of a new variable. Or, if your language lets you make local redefinitions of names in an outer scope: Remove the local (re)definition, and your code will reference a completely different variable. The "uber" approach makes available to you a whole lot that you are not aware of, not its origins. You won't have an error message that a declaration is missing. You don't know what you are making use of. One day someone adds a similarly defined function to your project, doing things in a different way, and your code fails ... Ideally, you should know every single instruction your code executes. That is of course impossible; we have to rely on libraries, OS functions etc., but we select them, deliberately and concerned. The "uber" approach invites to introducing a lot of code that is not at all selected, neither deliberately nor concerned, it just is there, ready to manipulate your data in ways that you do not know. Blackboxing principles go both ways: Your class, module, namespace or whatever should not expose more of itself that what is absolutely necessary for others to know. But at the same time: Inside that black box, you should not see more of the environment than absolutely necessary for the blackbox to know. One of the nice features of VS is that it tells when you are using namespaces, but not using any names from them!

                Religious freedom is the freedom to say that two plus two make five.

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

                trønderen wrote:

                I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need

                Easy Peasy:

                [k5054@localhost]$ cat ex1.cpp
                #include int main()
                {
                std::cout << "Hello World\n";
                }
                [k5054@localhost]$ time g++ ex1.cpp

                real 0m0.208s
                user 0m0.148s
                sys 0m0.058s
                [k5054@localhost]$ cat ex2.cpp
                #include int main()
                {
                std::cout << "Hello World\n";
                }
                [k5054@localhost]$ time g++ ex2.cpp

                real 0m0.865s
                user 0m0.718s
                sys 0m0.142s
                [k5054@localhost]$

                That's a 400% slow down. I've never done that in real life. I stumbled across bits/stdc++.h only a couple of years ago, I think in QA. Not sure why the GNU maintainers allowed it. It seems like a good way to get a whole raft of unexpected results.

                "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

                T 1 Reply Last reply
                0
                • L Lost User

                  Sort of in reverse direction, opposite intelisense way.

                  Is there?

                  concluding from discussion which "went sideways" ( am I allowed to have an opinion ?) there is no such option

                  T Offline
                  T Offline
                  trønderen
                  wrote on last edited by
                  #9

                  Fair enough, but your quote is not from the post that you have attached your comment to. (I am not offended, I just want to point it out.)

                  Religious freedom is the freedom to say that two plus two make five.

                  1 Reply Last reply
                  0
                  • K k5054

                    trønderen wrote:

                    I could challenge you to create a setup to prove the significance of this: A compilation that would consistently take noticeably (more than 1%) longer compilation time with an "uber include" than with individual includes for what you really need

                    Easy Peasy:

                    [k5054@localhost]$ cat ex1.cpp
                    #include int main()
                    {
                    std::cout << "Hello World\n";
                    }
                    [k5054@localhost]$ time g++ ex1.cpp

                    real 0m0.208s
                    user 0m0.148s
                    sys 0m0.058s
                    [k5054@localhost]$ cat ex2.cpp
                    #include int main()
                    {
                    std::cout << "Hello World\n";
                    }
                    [k5054@localhost]$ time g++ ex2.cpp

                    real 0m0.865s
                    user 0m0.718s
                    sys 0m0.142s
                    [k5054@localhost]$

                    That's a 400% slow down. I've never done that in real life. I stumbled across bits/stdc++.h only a couple of years ago, I think in QA. Not sure why the GNU maintainers allowed it. It seems like a good way to get a whole raft of unexpected results.

                    "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

                    T Offline
                    T Offline
                    trønderen
                    wrote on last edited by
                    #10

                    Yeah, that's what I expected. I do not consider your example fully qualifying, though. I was speaking of "showing significant higher compilation times". I do not consider 600 and some milliseconds extra compilation time to be "significant". If milliseconds really count, you might delete all sorts of 'copyleft'-like blurb in all your header files, reduce all whitespace to single spaces and use single/few character symbols wherever possible. As I mentioned earlier, there are several good reasons against the "über" philosophy. I do not count saving 600 ms wall clock time as one of them.

                    Religious freedom is the freedom to say that two plus two make five.

                    1 Reply Last reply
                    0
                    • L Lost User

                      Sort of in reverse direction, opposite intelisense way.

                      Is there?

                      concluding from discussion which "went sideways" ( am I allowed to have an opinion ?) there is no such option

                      B Offline
                      B Offline
                      BernardIE5317
                      wrote on last edited by
                      #11

                      May I please inquire are you stating the compiler you are utilizing provides no means to specify a list of directories to search for #include's. That is difficult to believe. May I please inquire compiler purveyor.

                      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