crazy novice
crazy novice

Reputation: 1817

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

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?

Upvotes: 1

Views: 15348

Answers (1)

jamesdlin
jamesdlin

Reputation: 89965

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.)

Upvotes: 12

Related Questions