#define PI 3.14
//产生新类型
typedef 3.14 PI单字符,一个字节存储,宽字符,二个字节存储。sizeof(L"abc")=8
size("abc")=4typedef unsigned short wchar_t;
chartypedef wchar_t WCHAR;
typedef char CHAR;WCHAR* p = L"Hello";
CHAR* = "Hello";typedef const CHAR* CSTR;
typedef const WCHAR* CWSTR;
typedef const CHAR* LPCSTR;
LPCSTR = PCSTR单字符版本
宽字符版本
#ifdef _UNICODE
#define TEXT(x) L##x => L"x"
#else
#define TEXT(x) x
#endif#define _T(x) TEXT(x)SetWindowText(TEXT("QQ"))
SetWindowText(_T("QQ"))#ifdef _UNICODE
#define PTSTR PWSTR
#else
#define PTSTR PSTR
#endif#ifdef _UNICODE
#define PCTSTR PCWSTR
#else
#define PCTSTR PCSTR
#endif#ifdef _UNICODE
#define _tWinMain wWinMain
#else
#define _tWinMain WinMain
#endif
工程属性设置中,编码使用Unicode,则使用宽字符,PCTSTR => const wchar_t*
使用多字节,PCTSTR => const char*
推荐一个零声学院项目课,个人觉得老师讲得不错,分享给大家:
零声白金学习卡(含基础架构/高性能存储/golang云原生/音视频/Linux内核)
https://xxetb.xet.tech/s/3Zqhgt