这是我第一次使用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...




谢谢你的帮助!

最佳答案

看起来您已经包含相同的标头,并且在其中多次键入了这些定义。使用include guards避免多个包含。

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

10-14 16:57
查看更多