哪个C/C++头文件定义了BYTE数据类型?

问题描述:

我移植头同意本声明:哪个C/C++头文件定义了BYTE数据类型?

struct tMaterialInfo {  
    char strName[255]; // the texture name 
    char strFile [255]; // the texture 
    BYTE color [3]; // the color of the object 
}; 

头具有以下包括:

#include <windows.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <math.h> 
#include <fstream> 
#include <vector> 
#include <gl\gl.h> // Header File For The OpenGL32 Library 
#include<gl\glu.h>// Header File For The GLu32 Library 
#include <gl\glaux.h> 

在这情况下BYTE从何而来?

+1

+1定义明确说明的问题,以及提供足够的上下文提供一个有用的答案。 – RBerteig 2010-12-20 01:12:05

我猜这是从Windows

一个字节(8位)。

此类型在WINDEF.H声明如下:

的typedef无符号字符BYTE;

+5

而且应该补充说不应该使用它。所有大写整数/字符串类型都是无用的代码丑化,仅用于使代码不必要地与Windows绑定。只需使用相应的标准类型,如'unsigned char'或'uint8_t'(如果后者完全相同,它们必须相同)。 – 2010-12-20 01:49:06

+1

直到2010年,stdint才被添加到Visual Studio中。 – 2010-12-20 01:53:22

+10

如果您使用的是WINAPI函数,则应该使用Windows数据类型。 http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/c066968d-8cb7-4e5a-9807-aa9cd47c65ed – 2010-12-20 02:01:23

几乎可以肯定地从包含从windows.h包括的许多标题之一。至少在Windows 2.0的日子里(我记得最早的Windows SDK),Windows SDK包含typedef的​​,WORDDWORD

如果您正在为Windows编程C,我假设您正在使用Visual Studio进行开发。您可以右键点击的任何关键字并选择转到定义F12找到它的定义。

字节是WINDEF.H

typedef unsigned char  BYTE;