问个弱弱的问题:标准C++中,使用uint8 uint16 uint32类型需要包含什么头文件?

江南烟雨梦 2010-04-20 12:05:17
问个弱弱的问题:标准C++中,使用uint8 uint16 uint32类型需要包含什么头文件?
...全文
101924 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
[PE]经典八炮 2021-06-13
  • 打赏
  • 举报
回复

stdint.h

我被坑了很长时间了,我的编译器竟然不提示包含头文件,反而直接把uint8_t忽略了,结果导致一大堆莫名其妙的错误

VS2019奇怪的编译错误系列之一:使用uint8_t等类型报错_一位编程爱好者的博客-CSDN博客

lilingmzai 2011-08-19
  • 打赏
  • 举报
回复
如果VS因为不认识UINT开头的相关变量类型报syntax error错误,
7楼说法正确,可加头文件#include<BaseTsd.h>,已验证。
walterclozet 2011-01-25
  • 打赏
  • 举报
回复
标准C++中暂时还没有这方面的规定, 因为C99比现行的C++标准迟. 不过有些编译器里已经有cstdint了. 在未来的c++0x中用#include<cstdint>即可.
zqlclj 2010-04-20
  • 打赏
  • 举报
回复
自已定义
江南烟雨梦 2010-04-20
  • 打赏
  • 举报
回复
来位高手?
江南烟雨梦 2010-04-20
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhoutanliang 的回复:]
不要头文件
[/Quote]
但是报错啊!说uint8未定义!
AlanBruce 2010-04-20
  • 打赏
  • 举报
回复
不要头文件
bigtankbigtank 2010-04-20
  • 打赏
  • 举报
回复
standard C99中要求包含<stdint.h>
编程-鸟人-_-- 2010-04-20
  • 打赏
  • 举报
回复 1
自己定义!给一份ucos-ii的数据类型定义:
/
****************************************************
Date types(Compiler specific) 数据类型(和编译器相关)
*****************************************************/
typedef unsigned char uint8; /* Unsigned 8 bit quantity */
typedef signed char int8; /* Signed 8 bit quantity */
typedef unsigned short uint16; /* Unsigned 16 bit quantity */
typedef signed short int16; /* Signed 16 bit quantity */
typedef unsigned int uint32; /* Unsigned 32 bit quantity */
typedef signed int int32; /* Signed 32 bit quantity */
typedef float fp32; /* Single precision */
/* floating point */
typedef double fp64; /* Double precision */
/* floating point */

可以参考下!
编程-鸟人-_-- 2010-04-20
  • 打赏
  • 举报
回复
自己定义!给一份ucos-ii的数据类型定义:

/****************************************************
Date types(Compiler specific) 数据类型(和编译器相关)
*****************************************************/
typedef unsigned char uint8; /* Unsigned 8 bit quantity */
typedef signed char int8; /* Signed 8 bit quantity */
typedef unsigned short uint16; /* Unsigned 16 bit quantity */
typedef signed short int16; /* Signed 16 bit quantity */
typedef unsigned int uint32; /* Unsigned 32 bit quantity */
typedef signed int int32; /* Signed 32 bit quantity */
typedef float fp32; /* Single precision */
/* floating point */
typedef double fp64; /* Double precision */
/* floating point */
可以参考下!
fairuyy 2010-04-20
  • 打赏
  • 举报
回复
不会查MSDN??
zhangweiit 2010-04-20
  • 打赏
  • 举报
回复
标准库的时候,是这样的
一般的类型,只要是c99标准后的,不需要加头文件
高级一些的类型,会以_t结尾,如size_t,int8_t,
或是以 _ 打头,如_Bool
有stdbool.h,stdint.h这些头文件
这些也不用太担心,需要用到具体某个类型的时候再来查
lgz1989cn 2010-04-20
  • 打赏
  • 举报
回复
#include <BaseTsd.h>
赵4老师 2010-04-20
  • 打赏
  • 举报
回复
C:\Program Files\Borland\CBuilder6\Include\stdint.h
/* stdint.h

Integer types - c99 7.18
*/

/*
* C/C++ Run Time Library - Version 11.0
*
* Copyright (c) 2002 by Borland Software Corporation
* All Rights Reserved.
*
*/


#ifndef __STDINT_H
#define __STDINT_H

/* 7.18.1.1 Exact-width integer types */

typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;

typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;



/* 7.18.1.2 Minimum-width integer types */

typedef __int8 int_least8_t;
typedef __int16 int_least16_t;
typedef __int32 int_least32_t;
typedef __int64 int_least64_t;

typedef unsigned __int8 uint_least8_t;
typedef unsigned __int16 uint_least16_t;
typedef unsigned __int32 uint_least32_t;
typedef unsigned __int64 uint_least64_t;



/* 7.18.1.3 Fastest minimum-width integer types */

typedef __int8 int_fast8_t;
typedef __int16 int_fast16_t;
typedef __int32 int_fast32_t;
typedef __int64 int_fast64_t;

typedef unsigned __int8 uint_fast8_t;
typedef unsigned __int16 uint_fast16_t;
typedef unsigned __int32 uint_fast32_t;
typedef unsigned __int64 uint_fast64_t;



/* 7.18.1.4 Integer types capable of holding object pointers */

typedef int32_t intptr_t;
typedef uint32_t uintptr_t;



/* 7.18.1.5 Greatest-width integer types */

typedef int64_t intmax_t;
typedef uint64_t uintmax_t;



/* 7.18.2.1 Limits of exact-width integer types */

#define INT8_MIN ((int8_t) -128)
#define INT16_MIN ((int16_t) -32768)
#define INT32_MIN ((int32_t) -2147483648)
#define INT64_MIN ((int64_t) -9223372036854775808)

#define INT8_MAX ((int8_t) 127)
#define INT16_MAX ((int16_t) 32767)
#define INT32_MAX ((int32_t) 2147483647)
#define INT64_MAX ((int64_t) 9223372036854775807)

#define UINT8_MAX ((uint8_t) 255)
#define UINT16_MAX ((uint16_t) 65535)
#define UINT32_MAX ((uint32_t) 4294967295)
#define UINT64_MAX ((uint64_t) 18446744073709551615)



/* 7.18.2.2 Limits of minimum-width integer types */

#define INT_LEAST8_MIN ((int_least8_t) -128)
#define INT_LEAST16_MIN ((int_least16_t) -32768)
#define INT_LEAST32_MIN ((int_least32_t) -2147483648)
#define INT_LEAST64_MIN ((int_least64_t) -9223372036854775808)

#define INT_LEAST8_MAX ((int_least8_t) 127)
#define INT_LEAST16_MAX ((int_least16_t) 32767)
#define INT_LEAST32_MAX ((int_least32_t) 2147483647)
#define INT_LEAST64_MAX ((int_least64_t) 9223372036854775807)

#define UINT_LEAST8_MAX ((uint_least8_t) 255)
#define UINT_LEAST16_MAX ((uint_least16_t) 65535)
#define UINT_LEAST32_MAX ((uint_least32_t) 4294967295)
#define UINT_LEAST64_MAX ((uint_least64_t) 18446744073709551615)



/* 7.18.2.3 Limits of fastest minimum-width integer types */

#define INT_FAST8_MIN ((int_fast8_t) -128)
#define INT_FAST16_MIN ((int_fast16_t) -32768)
#define INT_FAST32_MIN ((int_fast32_t) -2147483648)
#define INT_FAST64_MIN ((int_fast64_t) -9223372036854775808)

#define INT_FAST8_MAX ((int_fast8_t) 127)
#define INT_FAST16_MAX ((int_fast16_t) 32767)
#define INT_FAST32_MAX ((int_fast32_t) 2147483647)
#define INT_FAST64_MAX ((int_fast64_t) 9223372036854775807)

#define UINT_FAST8_MAX ((uint_fast8_t) 255)
#define UINT_FAST16_MAX ((uint_fast16_t) 65535)
#define UINT_FAST32_MAX ((uint_fast32_t) 4294967295)
#define UINT_FAST64_MAX ((uint_fast64_t) 18446744073709551615)



/* 7.18.2.4 Limits of integer types capable of holding object pointers */

#define INTPTR_MIN ((intptr_t) -32768)
#define INTPTR_MAX ((intptr_t) 32767)
#define UINTPTR_MAX ((intptr_t) 65535)



/* 7.18.2.5 Limits of greatest-width integer types */

#define INTMAX_MIN ((intmax_t) -9223372036854775808)
#define INTMAX_MAX ((intmax_t) 9223372036854775807)
#define UINTMAX_MAX ((uintmax_t) 18446744073709551615)



/* 7.18.3 Limits of other integer types */

#define PTRDIFF_MIN ((int32_t) -65536)
#define PTRDIFF_MAX ((int32_t) 65535)

#ifdef __STDC_LIMIT_MACROS
#define SIG_ATOMIC_MIN INT32_MIN
#define SIG_ATOMIC_MAX INT32_MAX
#endif

#define SIZE_MAX 65535

#ifdef __STDC_CONSTANT_MACROS
#define WCHAR_MIN INT16_MIN
#define WCHAR_MAX INT16_MAX
#define WINT_MIN INT16_MIN
#define WINT_MAX INT16_MAX
#endif



/* 7.18.4.1 Macros for minimum-width integer constants */

#define INT8_C(x) ((int8_t) x)
#define INT16_C(x) ((int16_t) x)
#define INT32_C(x) ((int32_t) x)
#define INT64_C(x) ((int64_t) x)

#define UINT8_C(x) ((uint8_t) x)
#define UINT16_C(x) ((uint16_t) x)
#define UINT32_C(x) ((uint32_t) x)
#define UINT64_C(x) ((uint64_t) x)



/* 7.18.4.2 Macros for greatest-width integer constants */

#define INTMAX_C(x) ((intmax_t) x)
#define UINTMAX_C(x) ((uintmax_t) x)

#endif /* __STDINT_H */
happynxy 2010-04-20
  • 打赏
  • 举报
回复
#include <stdint.h>

不过是unit8_t,不是uint8

64,647

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧