简体   繁体   English

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

[英]error while make runs. Conflicting types and previous declaration

I found an implementation of AES for a project I'm doing. 我找到了我正在做的项目的AES实现。

However when i integrate it I'm getting the following errors during the build. 但是,当我集成它时,在构建过程中出现以下错误。

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

The header file itself is: 头文件本身是:

// 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);

and then the respective C file uses. 然后使用相应的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
}

I know these errors usually occur because either the function hasn't been pre-declared or because it's slightly different to it's declaration, but I can't see a difference. 我知道这些错误通常是由于尚未预先声明函数或与声明稍有不同而发生的,但是我看不出有什么区别。

Any ideas? 有任何想法吗?

What compiler are you using? 您正在使用什么编译器? My best guess that it's trying to say aes.h is being #include d twice. 我最好的猜测是它试图说aes.h#include d两次。 Try adding header guards at the beginning and end of the aes.h : 尝试在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_ */

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以前的声明和冲突的类型 - Previous declaration and conflicting types 类型和先前的函数声明冲突? - Conflicting types and previous declaration of function? 错误:“…”的类型冲突; 注意:之前的隐式声明“…”在这里 - error: conflicting types for '…'; note: previous implicit declaration of '…' was here 错误:'f'的冲突类型和'f'的先前声明在这里 - error: conflicting types for 'f' and previous declaration of 'f' was here 类型冲突和C中的先前隐式声明 - conflicting types AND previous implicit declaration in C x的冲突类型和先前的声明在这里......什么? - Conflicting types and previous declaration of x was here…what? Mingw -- 由于先前的声明而导致函数类型冲突 - Mingw -- Conflicting types for function due to previous declaration 得到错误:“错误:'call_celsius'的类型冲突”和“注意:此处先前的'call_celsius'的隐式声明在这里” - Getting errors: “error: conflicting types for ‘call_celsius’ ” and “note: previous implicit declaration of ‘call_celsius’ was here” gcc在编译过程中错误“冲突类型”和“先前声明” - gcc errors “conflicting types for” and “previous declaration of” during compiling 在应用程序运行时,使嵌入可执行文件的二进制 blob 作为文件系统文件可访问。 C/C++ - Make executable-embedded binary blob accessible as a filesystem file while app runs. C/C++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM