C 运行时出错。冲突类型和以前的声明

C 运行时出错。冲突类型和以前的声明,c,embedded,C,Embedded,我为我正在做的一个项目找到了AES的实现 然而,当我集成它时,我在构建过程中会遇到以下错误 In file included from ff.h:26:0, from disp.h:4, from main.c:14: aes.h:14:3: error: conflicting types for 'AesCtx' aes.h:14:3: note: previous declaration of 'AesCtx' was here aes.

我为我正在做的一个项目找到了AES的实现

然而,当我集成它时,我在构建过程中会遇到以下错误

In file included from ff.h:26:0,
             from disp.h:4,
             from main.c:14:
aes.h:14:3: error: conflicting types for 'AesCtx'
aes.h:14:3: note: previous declaration of 'AesCtx' was here
aes.h:28:5: error: conflicting types for 'AesCtxIni'
aes.h:28:5: note: previous declaration of 'AesCtxIni' was here
aes.h:29:5: error: conflicting types for 'AesEncrypt'
aes.h:29:5: note: previous declaration of 'AesEncrypt' was here
aes.h:30:5: error: conflicting types for 'AesDecrypt'
aes.h:30:5: note: previous declaration of 'AesDecrypt' was here
头文件本身是:

// AES context structure
typedef struct {
 unsigned int Ek[60];
 unsigned int Dk[60];
 unsigned int Iv[4];
 unsigned char Nr;
 unsigned char Mode;
} AesCtx;

// key length in bytes
#define KEY128 16
#define KEY192 24
#define KEY256 32
// block size in bytes
#define BLOCKSZ 16
// mode
#define EBC 0
#define CBC 1

// AES API function prototype

int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode);
int AesEncrypt(AesCtx *pCtx, unsigned char *pData, unsigned char *pCipher, unsigned int DataLen);
int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);
然后相应的C文件使用

int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode)
{
    // Cut out code for brevity
}

int AesEncrypt(AesCtx *pCtx, unsigned char *pData, unsigned char *pCipher, unsigned int DataLen)
{
    // Cut out code for brevity
}

int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen)
{
    // Cut out code for brevity
}
我知道这些错误通常是因为函数没有被预先声明,或者因为它与它的声明略有不同,但我看不出有什么不同


有什么想法吗?

你在用什么编译器?我的最佳猜测是,它试图说
aes.h
#include
d两次。尝试在
aes.h
的开头和结尾添加标题保护:

#ifndef AES_H_
#define AES_H_

typedef struct {
...
int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);

#endif /* !AES_H_ */

你在用什么编译器?我的最佳猜测是,它试图说
aes.h
#include
d两次。尝试在
aes.h
的开头和结尾添加标题保护:

#ifndef AES_H_
#define AES_H_

typedef struct {
...
int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);

#endif /* !AES_H_ */

非常感谢,这就是问题所在。我没有注意到这很愚蠢,项目中的所有其他头文件都有这个保护。非常感谢,这就是问题所在。我没有注意到这很愚蠢,项目中的所有其他头文件都有这种保护。