Hey, everyone. I'm reaching my limit of C language understanding with this question. I've got some sample code written by Freescale, as part of one of their demo boards, the DEMO9S08AW60E. There are the following macros in one of the header files:
#define _DEBUGT(a) Debugt(a) #define _DEBUGI(a) Debugi(a) #define _DEBUGC(a) Debugc(a) #define _DEBUGNL Debugnl()
My question is, what is the point of making such a subsitution of function names for what looks like preprocessor directive names?
Solved! Go to Solution.
Hello irob,
In all probability the real macros were named with upper case and underscore, but one or more files used the same macros, but with the alternative naming. The use of the header file would avoid the need to change every instance of the macro use within these files, or create a second set of macros with the different naming.
This practice is obviously not helpful in the understanding of the code operation, probably requiring the knowledge of the contents of two header files instead of one.
Regards,
Mac
Hello irob,
In all probability the real macros were named with upper case and underscore, but one or more files used the same macros, but with the alternative naming. The use of the header file would avoid the need to change every instance of the macro use within these files, or create a second set of macros with the different naming.
This practice is obviously not helpful in the understanding of the code operation, probably requiring the knowledge of the contents of two header files instead of one.
Regards,
Mac
Hello irob,
For C coding, keep in mind that the preprocessor handles the macros by simply providing text substitution, with the possibility of multiple substitutions if macros are included within macros. You can always determine what final substitutions have been made by running the preprocessor alone for the project. This can be a very useful debug tool.
Regards,
Mac