#包括<螺纹>和错误C2371:'int8_t':重新定义;不同的基本类型 [英] #include<thread> and error C2371: 'int8_t' : redefinition; different basic types

查看:1178
本文介绍了#包括<螺纹>和错误C2371:'int8_t':重新定义;不同的基本类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我一直致力于为我正在研究的程序添加功能,并希望使用std :: Threads添加多线程。我注意到的是当添加#include< thread>时错误错误C2371发生编译错误:'int8_t':redefinition;不同的基本类型



可以做些什么来纠正这个?

Hello all,
I've been working on adding functionality to a program I'm working on and would like to use std::Threads to add multi-threading. What I've noticed is that when adding #include<thread> a compilation error occurs with the error-error C2371: 'int8_t' : redefinition; different basic types"

What can be done to correct this?

推荐答案

KarnstenK有点给你正确的答案,但它需要扩大



有两个单位都试图定义int8_t,其中一个是标准C库的一部分,它将在系统中的StdInt.H包含任何C99兼容编译器的目录。



固定宽度整数类型(自C99起)

http://en.cppreference.com/w/c/types/integer [ ^ ]



正如您使用的标准库那样无法绕过该单元。



您需要找到也试图定义int8_t的无系统单元并查看是否你可以修复它。使用#ifndef thru重命名非stan有很多方法可以做到这一点。使用int8_t到新名称的dard单元。



但是要开始你需要找到包含名称int8_t的第二个单元,因为它实际上不应该是定义该特定名称,我个人会修复该单位。
KarnstenK sort of gives you the correct answer but it needs expanding

There are two units both trying to define "int8_t" and one of those is part of the standard C library it will be in "StdInt.H" in the system include directory of any C99 compliant compiler.

Fixed width integer types (since C99)
http://en.cppreference.com/w/c/types/integer[^]

As you are using the standard libraries that you can not get around that unit.

You need to find the none system unit that is also trying to define int8_t and see if you can fix it. There are a number of ways to do that from using #ifndef thru to renaming the non standard unit using of int8_t to a new name.

However to start you need to find what the second unit is that contains the name int8_t because it really shouldn't be defining that particular name and personally I would fix that unit.


int8_t 应该在 cstdint中定义标题。可能一个非标准的标题重新定义了它。我很确定编译器报告了什么是冲突的标题。
int8_t should be defined in cstdint header. Possibly a non-standard header redefines it. I am pretty sure the compiler is reporting what are the conflicting headers.


你必须更改包含的标题。排除你真正需要的标题(主要),找到其中定义的部分并尝试将其排除,或者在主要之后加入辅助标题。



在大多数情况下,某种程度上是项目的配置问题。
you got to change the included headers. Exclude the header which you REALLY NEED ("primary"), to find the part where else it is defined and try to exlude it, or include the "secondary" header AFTER the "primary".

It is in most cases somehow an configuration problem of your project.


这篇关于#包括&LT;螺纹&GT;和错误C2371:'int8_t':重新定义;不同的基本类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆