EagleOne
EagleOne

Reputation: 571

Declaration is incompatible

I was working with IAR Embedded Workbench, using C language.

I had some trouble while dividing my project into the usual main/.h/.c form.

For example, if i create an example.h

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

And than an example.c

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

It says:

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 

Upvotes: 3

Views: 22752

Answers (3)

Ashish
Ashish

Reputation: 480

In IAR, you will see this error when declaration and definition will not be matching. For Ex- if you declare your variable as __ro_placement in .hpp and during initialization in .c or .cpp, if you will not provide __ro_placement with variable, IAR will throw same error.

Upvotes: 0

i486
i486

Reputation: 6563

The problem is in void function(int [], int). Change to void function(int name[], int) or void function(int *, int). Another error is in int[] array - it has to be int array[] or int * array.

Upvotes: 3

AnatolyS
AnatolyS

Reputation: 4319

You use wrong syntax. Look at

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

Upvotes: 2

Related Questions