#include <iostream>
#include <string>
#define XX_VERSION_MAJOR 1 // 主版本號
#define XX_VERSION_MINOR 1 // 副版本號
#define XX_VERSION_REVISION 1 // 修正版本號
#define XX_VERSION_STATUS "Alpha"
#define XX_AUX_STR_EXP(__A) #__A
#define XX_AUX_STR(__A) XX_AUX_STR_EXP(__A)
// 寬字符表示
#define XX_AUX_WSTR_EXP(__A) L ## #__A
#define XX_AUX_WSTR(__A) XX_AUX_WSTR_EXP(__A)
#define XX_VERSION_STR XX_AUX_STR(XX_VERSION_MAJOR) "." \
XX_AUX_STR(XX_VERSION_MINOR) "." \
XX_AUX_STR(XX_VERSION_REVISION) " " \
XX_VERSION_STATUS
#define XX_VERSION_WSTR XX_AUX_WSTR(XX_VERSION_MAJOR) "." \
XX_AUX_WSTR(XX_VERSION_MINOR) "." \
XX_AUX_WSTR(XX_VERSION_REVISION) " " \
XX_VERSION_STATUS
int main(int argc, char *argv[])
{
std::cout << XX_VERSION_STR << std::endl;
std::wcout << XX_VERSION_WSTR << std::endl;
std::string str = XX_VERSION_STR;
std::wstring wstr = XX_VERSION_WSTR;
std::cout << str << std::endl;
std::wcout << wstr << std::endl;
return 0;
}
編譯器: gcc 7.4.0
結果: