Results 1 to 2 of 2

Thread: Use 1 global header file for all declarations?

  1. #1
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default Use 1 global header file for all declarations?

    Should I use a single header file for all declarations like "Windows.h"? or use a header file per class? What do you prefer? If I include more than what I need, will the linker automatically removes any unused code?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Use 1 global header file for all declarations?

    Quote Originally Posted by grayfox
    Should I use a single header file for all declarations like "Windows.h"? or use a header file per class? What do you prefer?
    If every thing depends on each other, or all these things are supposed to in under one big module then use one global include.

    If your code is chunks of reused modules, where some modules are used acrross projects, then have one file include file per module.

    It all depends on how modular and reusable you want to make your software, in fact it is one of the design considerations, how to organize the source code, there are no strict rules for it. At the end of the day it should compile and work.

    Quote Originally Posted by grayfox
    If I include more than what I need, will the linker automatically removes any unused code?
    Only the used code is linked.

  3. The following user says thank you to Santosh Reddy for this useful post:

    grayfox (23rd July 2011)

Similar Threads

  1. Qt Creator How to auto-create function blocks from header declarations?
    By Asperamanca in forum Qt Tools
    Replies: 1
    Last Post: 29th October 2010, 09:21
  2. C++ forbids declarations with no type
    By brianc in forum Newbie
    Replies: 3
    Last Post: 5th August 2010, 23:09
  3. Replies: 2
    Last Post: 14th October 2008, 09:05
  4. Forward declarations needed for some?
    By doktorn in forum Newbie
    Replies: 6
    Last Post: 28th November 2007, 08:56
  5. Related to header file
    By merry in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2007, 13:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.