Results 1 to 2 of 2

Thread: DO we Need to include headers if we are using static Library in Nested scenario?

  1. #1
    Join Date
    Sep 2013
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default DO we Need to include headers if we are using static Library in Nested scenario?

    If I am using members of a class which a Static lib,Then I must add header file of that class in my .cpp.
    But, If that class is using some other libs, then should I include those other libs(class) header in my cpp file.

    ex= my program
    ==============
    need a class which in X.lib.
    I am using only X class object in
    my cpp.So I should include X class header
    in my file.
    But if X class in X.lib is using another lib Y.lib internally,
    then should I include Y class definition in my CPP?
    (I know Y.lib must be included in my project, but should Y.h should be included?)

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: DO we Need to include headers if we are using static Library in Nested scenario?

    You only need to include headers for declarations that you are using.

    So if you are using a class A, include the header where this class is declared.
    If that class is internally using a class B, then you are not using that class hence you don't need to include the declaration of B.

    This is totally independent of any form of linking. It is true for classes of the same project, for classes in static lbraries and for classes in dynamic libraries.
    (and of course for functions, constants, etc)

    Cheers,
    _

Similar Threads

  1. Qcreator include pleora libs and headers
    By Ricardo_arg in forum Qt Programming
    Replies: 11
    Last Post: 10th September 2013, 14:37
  2. uic3 generates #include's for non-existing headers
    By angel-tsankov in forum Qt Tools
    Replies: 1
    Last Post: 4th September 2010, 13:15
  3. Nested links on different static libraries
    By locke in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2010, 09:47
  4. Replies: 2
    Last Post: 24th May 2009, 17:05

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.