为什么未定义 PCTSTR 但定义了 LPCTSTR? [英] Why is PCTSTR not defined but LPCTSTR defined?

查看:28
本文介绍了为什么未定义 PCTSTR 但定义了 LPCTSTR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被指派更新用 MSVC++ 6 编写的旧代码.我得到了未知的 PCTSTR 定义,但即使我包含了 tchar.h,它也没有定义.根据我以前的经验,我知道有 LPTSTR 但没有 PCTSTR.

I have been assigned to update an old code written in MSVC++ 6. I have been getting unknown definition for PCTSTR but it was not defined even if I included the tchar.h. In my previous experience I know there is an LPTSTR but no PCTSTR.

我搜索了 C:\Program Files\Microsoft Visual Studio\VC98\Include\ 文件夹,但没有找到 PCTSTR 的定义.但令我惊讶的是,当我搜索 Windows SDK 文件夹 [C:\Program Files\Microsoft SDK] 时,没有 PCTSTR 的定义,但在其中一个示例中使用了它.[C:\Program Files\Microsoft SDK\Samples\winui\Resource\Iconpro*].所以我猜测这可能只是 16 位 Windows 的 Windows API 的遗物,但我无法从谷歌找到任何东西.

I grep the C:\Program Files\Microsoft Visual Studio\VC98\Include\ folder and did not found a definition of PCTSTR. But to my surprise when I searched the Windows SDK folder [C:\Program Files\Microsoft SDK] there was no definition of PCTSTR but it was used in one of the samples. [C:\Program Files\Microsoft SDK\Samples\winui\Resource\Iconpro*]. So I am guessing that this may just be a relic from the Windows API of 16-bit windows but I cannot find any thing from google.

有谁知道 PCTSTR 是干什么用的.我猜是因为这是来自旧代码,它以前有效.任何想法如何使这个编译?【我把这个改成LPCTSTR编译了,我想知道除了改定义名有没有其他方法】

Does anyone know what is the PCTSTR for. I am guessing since this was from an old code that this works before. Any ideas how to make this compile? [I changed this to LPCTSTR and it compiled, I want to know if there are other ways than changing the definition name]

推荐答案

LPCTSTR 中的 LP 表示长指针.它是 Windows 3 天后的一个神器,一个 16 位操作系统.当您只有一个 16 位 cpu 寄存器时,16 位代码有几种内存模型来处理尝试寻址超过 65536 字节的内存.短指针使用默认数据段寄存器值和 16 位偏移量.长指针是 32 位,16 位用于加载段寄存器,16 位用于偏移量.

The LP in LPCTSTR means Long Pointer. It is an artifact back from the Windows 3 days, a 16 bit operating system. 16-bit code had several memory models to deal with trying to address more than 65536 bytes of memory when you only have a 16-bit cpu register. A short pointer used the default data segment register value and a 16-bit offset. A long pointer was 32-bits, 16-bits to load a segment register and 16-bits for the offset.

LPCTSTR 中的 T 表示 TCHAR,是 char 或 wchar_t 的 typedef,具体取决于 UNICODE 宏的存在.

The T in LPCTSTR means TCHAR, a typedef for char or wchar_t, depending on the presence of the UNICODE macro.

这使得 PCTSTR 成为一种时代错误、人类和恐龙的电影​​风格.从来没有 16 位 Unicode 版本的 Windows,32 位版本的 Windows 总是使用 32 位指针.这听起来只是一个错误.尽管如此,当前版本的 winnt.h 确实 有一个 typedef,使其与 LPCTSTR 相同.并且只用在一个的地方,stralign.h 头文件带有一个名为 TSTR_ALIGNED_STACK_COPY 的奇怪函数.然而只在评论中.

Which makes PCTSTR a time anachronism, humans-and-dinosaurs movie style. There was never a 16-bit Unicode version of Windows, 32-bit versions of Windows always use 32-bit pointers. It sounds merely like a mistake. Enshrined though, the current version of winnt.h does have a typedef for it, making it the same as LPCTSTR. And used in only one place, the stralign.h header with a strange function named TSTR_ALIGNED_STACK_COPY. However only in a comment.

错误.您的解决方法是正确的选择.

Mistake. Your workaround was the right choice.

这篇关于为什么未定义 PCTSTR 但定义了 LPCTSTR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆