Last active
July 14, 2019 13:25
-
-
Save jstine35/dce098013e6bd28ceaa63c41a3945a1d to your computer and use it in GitHub Desktop.
Macro to allow rapid creation of enum->string conversion tables in C++, using column editing and switch statements.
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
#pragma once | |
///////////////////////////////////////////////////////////////////////////////////////////////// | |
// CaseReturnString( caseName ) | |
// | |
// Neat! Returns the case option as a string matching precisely the case label. Useful for logging | |
// hardware registers and for converting sparse enumerations into strings (enums where simple char* | |
// arrays fail). | |
// | |
#define CaseReturnString(caseName) case caseName: return # caseName | |
#define CaseReturnString2(ofs, caseName) case caseName: return # caseName + (ofs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment