Results 1 to 13 of 13

Thread: Combining include files

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Combining include files

    Quote Originally Posted by marcvanriet View Post
    This is new to me. Looking at qmake precompiled headers it's not really clear to me. It talks about precompiled headers, but the .pro file contains .cpp files also.
    There is no point in precompiling headers if you are not compiling any actual code, right?

    How would I use this for e.g. QExtSerialport ?
    I think you got it the wrong way. This is not used for projects you already have compiled but rather for projects you wish to compile. And it's not a mechanism for gathering many files into a single file but for speeding up processing header files by the compiler. You still need to have the actual header files should you wish to rebuild the pch file (i.e. when you want to add some more files to the database).

    Or can the .pch file be put in some common place and be re-used across projects ?
    In theory you can reuse the precompiled header for other projects but it only makes sense if you always use the same set of header files which is rarely the case. Of course unless you like having a several hundred megabyte file lying around on your disk and being read during every compilation cycle (taking up time and memory).

    I would use it for just this kind of libraries, of which there are dozens available on the internet : QExtSerialPort, Qwt, QSerialDevice, AnalogWidgets, ...
    Well, for Qwt it wouldn't make sense really. Unless you like to have your applications build several times longer. The larger the header file, the longer it takes for the toolchain to preprocess it. We rather want to avoid having to include files than including to many of them. There is a simple test - make a small Qt project consisting just of main() that creates a QString. Then include <QString> compile and measure the compilation time. Then replace <QString> inclusion with <QtCore> and rebuild, measuring time again (just using an appropriate system call and not your stopwatch). If you don't see a significant difference, replace <QtCore> with <QtGui> and add some more includes and then repeat the compilation cycle and measure the time again. Then draw conclusions from your observations and think whether you want that for all your projects.

    Of course I would only combine the include files of the library itself together, not the standard header files like stdarg.h. Hey, I'm not (that) stupid
    So what makes a "standard header file" different than "include file of the library itself"?


    .pri files are new to me also. As far as I understand, they are just files that are included in your .pro file. So how would I use these ? Create a .pri file for QExtSerialPort that adds the necessary include file paths for where I put QExtSerialport.
    Yes.
    Put this .pri file in the Qt include directory.
    No, you can put that anywhere you want as long as you know where it is.
    Reuse this .pri file in different projects of mine ?
    Yes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Combining include files

    So what makes a "standard header file" different than "include file of the library itself"?
    Well, the C standard library header files and Standard C++ header files and the Qt header files etc. In short : all the header files that are not distributed with the library that I wish to use.

    Anyway, how do you get it to work in wwWidgets with the CONFIG += wwWidgets ? That looks great !

    Regards,
    Marc

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Combining include files

    Quote Originally Posted by marcvanriet View Post
    Well, the C standard library header files and Standard C++ header files and the Qt header files etc. In short : all the header files that are not distributed with the library that I wish to use.
    "C standard library" header files are distributed with (g)libc, "Standard C++ header files" are distributed with libstdc++. They are libraries too, just like any other - there is nothing special in them, really.

    Anyway, how do you get it to work in wwWidgets with the CONFIG += wwWidgets ? That looks great !
    I use feature files for qmake. They are a bit like pri files just slightly more difficult to handle on the deployment end.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to include existing files to project?
    By Asperamanca in forum Qt Tools
    Replies: 2
    Last Post: 14th November 2009, 20:50
  2. Order of include files [c++ related]
    By Lykurg in forum Newbie
    Replies: 1
    Last Post: 10th November 2008, 12:56
  3. how to include object files in .pro file
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 1st July 2008, 08:23
  4. qmake: include files?
    By Doug Broadwell in forum Newbie
    Replies: 2
    Last Post: 16th May 2007, 23:34
  5. problem with include files
    By JR in forum General Discussion
    Replies: 2
    Last Post: 22nd December 2006, 20:44

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.