gpt4 book ai didi

c - 使用 cygwin gcc 时出现 typedef 定义错误

转载 作者:行者123 更新时间:2023-11-30 14:23:34 26 4
gpt4 key购买 nike

这是我第一次使用cygwin gcc,之前我在linux上使用过它。我遇到了一个问题解决方案,但在网上找不到。

我想编译 C 源文件并包含此源

// Value type defenitions
// --- chars --- //
typedef unsigned char UChar;
typedef char Char;
// --- short int --- //
typedef unsigned short UShort;
typedef short Short;
// --- int --- //
typedef unsigned int UInt;
typedef int Int;
// --- long int --- //
typedef long Long; // 32 bits length
typedef unsigned long ULong; // unsigned 32 bits length
// --- long long int --- //
typedef unsigned long long UBig; // 64-bit length unsigned
typedef long long Big; // 64-bit length
// --- decimals --- //
typedef float Float;
typedef double Double;
typedef long double Triple; // 80-bit length. Actual properties unspecified.

并出现此错误

Include/null.h:6: error: redefinition of typedef 'UChar'
Include/null.h:6: error: previous declaration of 'UChar' was here
Include/null.h:7: error: redefinition of typedef 'Char'
Include/null.h:7: error: previous declaration of 'Char' was here
Include/null.h:9: error: redefinition of typedef 'UShort'
Include/null.h:9: error: previous declaration of 'UShort' was here
and so on...
<小时/>

感谢您的帮助!

最佳答案

看起来您已经不止一次地包含了相同的 header ,其中您已经对这些进行了 typedef'edthese。使用include guards以避免多重包含。

关于c - 使用 cygwin gcc 时出现 typedef 定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12788062/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com