Results 1 to 4 of 4

Thread: A good system on header files

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default A good system on header files

    We define our errors in a header files. This file is shared to all apps and firmwares, now I am looking for a good way or system so the error viewer can be updated whenever there are changes in the definitions.
    This header file contains all the info that the viewer should show
    Qt Code:
    1. #define MYerror 1 /* hot unplug missed */
    2. #define yourerror 2 /*just do it error */
    To copy to clipboard, switch view to plain text mode 

    All suggestion is welcome

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A good system on header files

    You could use enum instead of macros. This way you can use Qt facilities like QMetaEnum.

  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A good system on header files

    Its a good idea but changing it to enums will affect lots of project (firmwares) that are not Qt some are C codes....

    The thing that i can think of is building a parser that outputs some .cpp file , in this file would be an initialized an
    Qt Code:
    1. map <int /*errorCode*/,string/*description*/> errorMap;
    2. map <int /*errorCode*/,string/*description*/> possibleCauseMap;
    3.  
    4. //since i have so many devices that has its own error code then this means another map
    5. // say....
    6.  
    7. map <int /*deviceId*/,map <int /*errorCode*/,string/*description*/> > deviceMapError;
    8. map <int /*deviceId*/,map <int /*errorCode*/,string/*description*/> > deviceMapPossibleCause;
    To copy to clipboard, switch view to plain text mode 

    parser is the only way i can think of .. but its a lot of work

    what do you think?

    baray98

  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: A good system on header files

    Quote Originally Posted by baray98 View Post
    Its a good idea but changing it to enums will affect lots of project (firmwares) that are not Qt some are C codes....
    Not quite. Values of enums are integers, so you can map between the two systems without a problem.

    In your case I would compile all error codes and messages into a global binary array and include it directly from within a header file to all projects.
    Of course the array would have to be constructed by some tool based on the parsed file (xml would be best, probably).

Similar Threads

  1. Replies: 4
    Last Post: 7th April 2010, 23:09
  2. header files not getting included
    By nimmyj in forum Installation and Deployment
    Replies: 1
    Last Post: 19th December 2006, 06:18
  3. qt3 themes example: missing header files?
    By nikita in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2006, 12:12

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.