1.首先把单个的.c文件全部设置成不使用预编译头(坑一)。
2.然后编译一下,提示GifFilePrivateType 未声明的标识(坑二),找到源文件里的定义声明:
typedef struct GifFilePrivateType {
GifWord FileState, FileHandle, /* Where all this data goes to! */
BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
ClearCode, /* The CLEAR LZ code. */
EOFCode, /* The EOF LZ code. */
RunningCode, /* The next code algorithm can generate. */
RunningBits, /* The number of bits required to represent RunningCode. */
MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */
LastCode, /* The code before the current code. */
CrntCode, /* Current algorithm code. */
StackPtr, /* For character stack (see below). */
CrntShiftState; /* Number of bits in CrntShiftDWord. */
unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
unsigned long PixelCount; /* Number of pixels in image. */
FILE *File; /* File as stream. */
InputFunc Read; /* function to read gif input (TVT) */
OutputFunc Write; /* function to write gif output (MRB) */
GifByteType Buf[256]; /* Compressed input is buffered here. */
GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
GifPrefixType Prefix[LZ_MAX_CODE + 1];
GifHashTableType *HashTable;
} GifFilePrivateType;
3.检查下发现这个文件头文件已经包含进去了,然后以为是C和C++ 结构体养发差异导致的,结果也没发现什么问题,然后把结构体里面的东西全删掉,编译通过,说明在结构体里定义的成员有没定义的,控制变量法最后发现只要有GifHashTableType *HashTable;就提示未声明标识的错误。
4.找到这个结构体的定义:
typedef struct GifHashTableType {
UINT32 HTable[HT_SIZE];
} GifHashTableType;
这个地方没定义。
5.知道了问题所在就好办了,前面加上typedef unsigned __int32 UINT32;坑二搞定!
6. 然后 FileHandle = open(FileName, O_WRONLY | O_CREAT | O_EXCL(坑三)
#if defined(__MSDOS__) || defined(WINDOWS32) || defined(_OPEN_BINARY)
| O_BINARY
#endif /* __MSDOS__ */
, S_IREAD | S_IWRITE);
又是未定义标识,这次真的有点慌,这好像是linux里面的东西,最后把代码注释掉,然后用windows的方法写一遍。