Results 1 to 4 of 4

Thread: Including Libraries respectively Header Files in the CORRECT Order

  1. #1
    Join Date
    Mar 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Including Libraries respectively Header Files in the CORRECT Order

    Dear Community,

    I had issues to include all my needed header files since they were in many different sub folders. However, I added them now manually. The drawback is that now a lot of "ISO C++ forbids declaration of 'desc' with no type [-fpermissive]" errors (around 130) occur. I think the reason is that the header files are included in wrong order, is that correct? So is there any way to find out which order is the correct/right one?


    Thank you.

    Nathi

  2. #2
    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: Including Libraries respectively Header Files in the CORRECT Order

    You have to resolve conflicts manually by reordering the statements in your code. However since this thread is a continuation of the other thread of yours then your approach is inherently broken and you might not be able to resolve such conflicts at all.

    Nevertheless I don't think the error you are getting is related to the order of includes. More likely a conflict between a define and a datatype name, a missing include or simply an error in your code (missing type declaration for the variable).

    Consider the following directory structure:

    dir1/file1.h
    dir1/file2.h

    dir2/file1.h
    dir2/file2.h

    Your code:
    Qt Code:
    1. #include "file1.h"
    2. #include "file2.h"
    To copy to clipboard, switch view to plain text mode 

    With "INCLUDEPATH += dir1 dir2" you will include dir1/file1.h and dir1/file2.h.
    With "INCLUDEPATH += dir2 dir1" you will include dir2/file1.h and dir2/file2.h.

    Now try writing code which includes dir1/file1.h and dir2/file2.h without using full paths to the include files (which you claim to be insane in the other thread).
    To make things harder have another file in your project where you want to include dir2/file1.h and dir1/file2.h
    Last edited by wysota; 6th March 2015 at 14:28.
    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.


  3. #3
    Join Date
    Mar 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Including Libraries respectively Header Files in the CORRECT Order

    Oh okay. Well thanks for this very illustrative explanation - this helps me to comprehend also my other thread and well I still think its insane that in 2015 it is still required to do that manually but well... So then I will take my weekend to work on including all the headers I need at the correct order.

    Greez
    Nathi

  4. #4
    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: Including Libraries respectively Header Files in the CORRECT Order

    Quote Originally Posted by Nathalia View Post
    I still think its insane that in 2015 it is still required to do that manually but well...
    I understand that if you open a commandline (e.g. cmd) on your computer and enter a name of a file then your command line searches your whole computer and all network volumes and executes that file and it does it fast and knows well which binary to execute if you have multiple files with the same name. It's year 2015 and my shell still searches only the directories set in PATH.
    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. Restore MDI Children w/correct window z-order
    By C403 in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2013, 22:00
  2. Replies: 2
    Last Post: 4th January 2012, 14:26
  3. How to add external Header files and libraries?
    By askbapi in forum Installation and Deployment
    Replies: 6
    Last Post: 30th September 2010, 18:33
  4. Including the QT libraries
    By hapheston in forum Installation and Deployment
    Replies: 3
    Last Post: 22nd August 2010, 14:23
  5. Replies: 2
    Last Post: 28th February 2010, 08:38

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.