BYTE as undeclared identifier even though I have included windows.h

梦想的初衷 提交于 2019-12-18 09:33:08

问题


My code is as follows

// 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;
}

creating following errors.

error C2065: 'BYTE' : undeclared identifier

What am I doing wrong here?


回答1:


You have #include "stdafx.h", which usually means that you're using a precompiled header. If you use a precompiled header, anything preceding the precompiled header will be discarded.

Try reordering your #include lines so that "stdafx.h" is first. (Or change stdafx.h to #include <windows.h>, which is generally where you want to put commonly-used system headers.)



来源:https://stackoverflow.com/questions/24900083/byte-as-undeclared-identifier-even-though-i-have-included-windows-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!