-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add common/macro.h for general-purpose macros.
Add GLUE() macro which is useful for creating identifiers. Move MACRO_TO_STR() here and rename it STRINGIFY(). This appears to be the standard name for this type of macro and it is also an awesome name.
- Loading branch information
Showing
7 changed files
with
35 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*********************************************************************************************************************************** | ||
General Macros | ||
***********************************************************************************************************************************/ | ||
#ifndef COMMON_MACRO_H | ||
#define COMMON_MACRO_H | ||
|
||
/*********************************************************************************************************************************** | ||
Convert the parameter to a zero-terminated string | ||
This is useful for converting non-string types (e.g. int) to strings for inclusion in messages. | ||
***********************************************************************************************************************************/ | ||
#define STRINGIFY_HELPER(param) #param | ||
#define STRINGIFY(param) STRINGIFY_HELPER(param) | ||
|
||
/*********************************************************************************************************************************** | ||
Glue together a string/macro and another string//macro | ||
Useful for creating function names when one or both of the macro parameter needs to be converted to a macro before concatenating. | ||
common/object.h has numerous examples of this. | ||
***********************************************************************************************************************************/ | ||
#define GLUE_HELPER(param1, param2) param1##param2 | ||
#define GLUE(param1, param2) GLUE_HELPER(param1, param2) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters