Thread: Can you make an overall include file?

  1. #1
    Registered User compjinx's Avatar
    Join Date
    Aug 2001
    Posts
    214

    Can you make an overall include file?

    can you make an overall include file that you can include all the include files?, like so:

    OVERALL.h:

    #ifndef MYGRAPHICSTUFF
    #include "MyGraphicStuff.h"
    #endif
    #ifndef MYSTRINGFUNCS
    #include "MyStringFuncs.h"
    #endif
    blah, blah....

    and then you ONLY include the above file ONCE for each CPP file and if you need to add another *.h file to your project then you just add it to this overall include file instead of having to type it into ALL the CPP files.

    is it OK to do this?

    if this question doesn't make any sense then wait till tomorrow and I will have a good nights sleep backing my mind.
    "The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
    Eric Porterfield.

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    It will work, but it's a bad idea. Files should only include that which they directly depend on.

  3. #3
    Registered User compjinx's Avatar
    Join Date
    Aug 2001
    Posts
    214

    ???

    why is it a bad idea?
    "The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
    Eric Porterfield.

  4. #4
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    >why is it a bad idea?

    It bloats files and slows them down.

  5. #5
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Plus if you change one tiny headerfile in use, it will recompile your whole project, as each and every cpp-file has it included. Can be a PITA.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM