Can you make an overall include file?

This is a discussion on Can you make an overall include file? within the C++ Programming forums, part of the General Programming Boards category; can you make an overall include file that you can include all the include files?, like so: OVERALL.h: #ifndef MYGRAPHICSTUFF ...

  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,825
    >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,139
    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, 04: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, 02:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21