宣言是不相容的

时间:2015-10-13 19:57:41

标签: c embedded workbench iar

我正在使用C语言与IAR Embedded Workbench合作。

将项目划分为通常的main / .h / .c格式时遇到了一些麻烦。

例如,如果我创建了一个example.h

#ifndef EXAMPLE_H
#define EXAMPLE_H
void function(int [], int);
#endif

而不是example.c

#include "example.h"
void function (int[] array, int number)
{number = 1; //code
}

它说:

Error[Pe147]: declaration is incompatible with "__interwork __softfp 
void function(int *, int)" (declared at line 4 of  (path)

Error[Pe141]: unnamed prototyped parameters not allowed when body is       present  (path)


Error[Pe020]: identifier "number" is undefined  (path)

Error while running C/C++ Compiler 

3 个答案:

答案 0 :(得分:3)

问题出在void function(int [], int)。更改为void function(int name[], int)void function(int *, int)。另一个错误是int[] array - 必须是int array[]int * array

答案 1 :(得分:2)

您使用错误的语法。看看

void function (int array[], int number)
{  number = 1; //code
}

答案 2 :(得分:0)

在IAR中,当声明和定义不匹配时,您会看到此错误。 对于Ex-,​​如果您在.hpp中将变量声明为__ro_placement,而在.c或.cpp中进行初始化,则如果不为__ro_placement提供变量,则IAR会抛出相同的错误。