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
Code:
#define MYerror 1 /* hot unplug missed */
#define yourerror 2 /*just do it error */
All suggestion is welcome
Re: A good system on header files
You could use enum instead of macros. This way you can use Qt facilities like QMetaEnum.
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
Code:
map <int /*errorCode*/,string/*description*/> errorMap;
map <int /*errorCode*/,string/*description*/> possibleCauseMap;
//since i have so many devices that has its own error code then this means another map
// say....
map <int /*deviceId*/,map <int /*errorCode*/,string/*description*/> > deviceMapError;
map <int /*deviceId*/,map <int /*errorCode*/,string/*description*/> > deviceMapPossibleCause;
parser is the only way i can think of .. but its a lot of work
what do you think?
baray98
Re: A good system on header files
Quote:
Originally Posted by
baray98
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).