Visual C ++自动将A或W附加到函数结尾 [英] Visual C++ Automatically Appending A or W to end of Function

查看:183
本文介绍了Visual C ++自动将A或W附加到函数结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中我已经定义了一个类作为成员:

  static const std :: basic_string< TCHAR>我的课_; 

这个值还有一个getter函数:

  LPCTSTR CClass :: GetMyClassName()
{
return MyClass_.c_str();
}

当我创建这个类的实例,然后尝试访问它intellisense但是名称已经更改,这取决于项目是否已编译为Unicode或Multibyte。如果它已经编译为Unicode,函数显示为:

  aClass.GetMyClassNameW 

否则为:

  aClass.GetMyClassNameA(); 

我想知道的是名称如何改变?
我还想知道是否可能intellisense显示正确的函数名称?所以我可以这样访问:

  aClass.GetMyClassName()

编辑:我在代码中使用的精确成员函数名是:

  WinClass :: GetClassName()


解决方案

p>您的方法名称字面上是 GetMyClassName 或者是 GetClassName



GetClassName位于SDK(winuser.h)中,并根据UNICODE定义重新定义。如果你使用GetClassName,intellisense可能会变得困惑;实际上编译器为实际编译的方法生成A / W后缀,但是这将工作,因为每个人(链接器/编译器)同意重新定义的名称(即使它不可见)。


In C++ I have defined a class that has this as a member:

static const std::basic_string<TCHAR> MyClass_;

There is also a getter function for this value:

LPCTSTR CClass::GetMyClassName()
{
    return MyClass_.c_str();
}

When I create an instance of this class and then try and access it intellisense pops up but the name has been changed depending on whether the project has been compiled for Unicode or Multibyte. If it has been compiled for Unicode the function appears as:

aClass.GetMyClassNameW();

else it is:

aClass.GetMyClassNameA();

What I'd like to know is how is the name getting changed? Also I would like to know is it possible for intellisense to show the correct name of the function? So that I can access it like this:

aClass.GetMyClassName()

EDIT: The precise member function name I've used in my code is:

WinClass::GetClassName()

解决方案

Your method name is literally "GetMyClassName" or is it "GetClassName"?

GetClassName is in the SDK (winuser.h) and is redefined based on the UNICODE defines. If you are using "GetClassName" the intellisense is probably getting confused; in fact the compiler is generating the A/W suffix for the actual compiled method as well but that would all work because everyone (Linker/Compiler) agrees on the redefined name (even if its not visible).

这篇关于Visual C ++自动将A或W附加到函数结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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