2013-07-09 37 views
5

我有以下代码中的问题:为什么Visual C++更改我的方法的名称?

class MainWindow 
{ 
... 
private: 
bool CreateWindow(std::string, int, int, int, bool); 
... 
} 

bool MainWindow::CreateWindow(std::string title, int width, int height, 
int bits, bool fullscreen) 
{ 
... 

Visual Studio中突出,下面的错误的方法的定义:

int reateWindow(std::string title, int width, int height, int bits, bool fullscreen) 
Error: class "MainWindow" has no member called "CreateWindowExW" 

和编译器输出以下:

warning C4003: not enough actual parameters for macro 'CreateWindowW' 
error C2039: 'CreateWindowExW' : is not a member of 'MainWindow' 

我注意到,如果我将方法名称更改为其他名称,那不是以大写字母C开头,则错误消失。我是Windows开发新手。是什么赋予了?

+3

TL; DR:因为有一个名称相同的宏。 –

+3

愚蠢的Windows宏。 – Xeo

+0

尽量避免Windows已经使用它的类和函数名称,以防止其他预处理器替换和链接问题。 – alexbuisson

回答

11

这很简单,因为CreateWindow是微软创建的宏... 它在WinUser.h中定义。

+0

感谢大家回答! –

+2

不要忘了将你的问题标记为已回答,将其从未回答的问题中删除:-) –

+1

更好地获得代表庇护所,以避免代罪; ;-) – TemplateRex

相关问题