BYTE作为未声明的标识符,即使我已经包含了windows.h

cra*_*ice 1 c++ console-application visual-studio-2013

我的代码如下

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include <windows.h>
#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
    BYTE* pAlloc1 = NULL;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

创建以下错误.

错误C2065:'BYTE':未声明的标识符

我在这做错了什么?

jam*_*lin 10

你有#include "stdafx.h",这通常意味着你正在使用预编译的头.如果使用预编译头,则将丢弃预编译头之前的任何内容.

尝试重新排序您的#include行,这"stdafx.h"是第一次.(或者更改stdafx.h#include <windows.h>,通常是您希望放置常用系统头的位置.)