Search code examples
cgcccygwin

typedef defenition error when I use cygwin gcc


It is my first experience with cygwin gcc, before that I used it on linux. I faced a problem solution for which I failed to find in net.

I want to compile C source file and have included this source

// 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. 

and have got this error

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

Thank you for help!


Solution

  • Looks like you have included the same header, where you have typedef'edthese, more than once. Use include guards to avoid multiple inclusion.