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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4486140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 15:31:31  来源:igfitidea点击:

Which C/C++ header file defines a BYTE data type?

c++cwindows

提问by andandandand

I'm porting a header with this declaration:

我正在移植带有此声明的标头:

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

The header has the following includes:

标题包含以下内容:

#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>

Where does that BYTE come from?

那个 BYTE 来自哪里?

回答by dsolimano

I'm guessing it's from Windows.

我猜它来自Windows

A byte (8 bits).

This type is declared in WinDef.h as follows:

typedef unsigned char BYTE;

一个字节(8 位)。

该类型在 WinDef.h 中声明如下:

typedef 无符号字符字节;

回答by andandandand

If you are programming C for Windows I assume you are using Visual Studioto develop. You can right clickon any keyword and select Go To DefinitionF12to find where it is defined.

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

BYTE is defined in WinDef.h

BYTE 在 WinDef.h 中定义

typedef unsigned char       BYTE;

回答by RBerteig

Almost certainly from one of the many headers included from windows.h. The Windows SDK has included typedefs for BYTE, WORD, and DWORDsince at least Windows 2.0 days (the earliest Windows SDK I recall having).

几乎可以肯定来自windows.h. Windows SDK 已经包含typedefBYTEWORD和 的s ,DWORD至少从 Windows 2.0 天开始(我记得最早的 Windows SDK)。